2017-12-13 12 views
0

は、どのように私はTextViewのためにこのスタイルを適用することができますしてください:私のスタイルは です:TextViewの親のタイプはどのようにして見つけることができますか?

<style name="styleCircle" parent=""> 

    <item name="textColor" >#000000</item> 
    <item name="textSize" >25sp</item> 
    <item name="android:background" >@drawable/azkar_shape</item> 
    <item name="android:gravity">center</item> 
    <item name="android:layout_width">100dp</item> 
    <item name="android:layout_height">100dp</item> 
    <item name="android:visibility">visible</item> 
    <item name="android:padding">5dp</item> 
    <item name="android:layout_marginTop">5dp</item> 

</style> 

私はこのタイプの親を見つける傾けます。私はそれがどのようにそれを実装するために私は、このエラー

Error:(1858) error: style attribute 'attr/textColor (aka com.almasbaha.yazeed:attr/textColor)' not found. Error:(1859) error: style attribute 'attr/textSize (aka com.almasbaha.yazeed:attr/textSize)' not found. Error:(1858) style attribute 'attr/textColor (aka com.almasbaha.yazeed:attr/textColor)' not found. Error:(1859) style attribute 'attr/textSize (aka com.almasbaha.yazeed:attr/textSize)' not found.

を与えたのTextViewが、 のための親の多くを試みたのですか?

答えて

0

<style>タグには、parent属性は必須ではありません。あなたはそれを放置することができます。

親は、スタイルセット内の1つの項目だけを変更する場合、スタイリング情報の巨大なブロックをコピー/貼り付けする必要がないように使用されます。この例では

<style name="MyBaseStyle"> 
    <item name="some_attribute_1">value</item> 
    <item name="some_attribute_2">value</item> 
    <item name="some_attribute_3">value</item> 
    <item name="some_attribute_4">value</item> 
</style> 

<style name="MyOtherStyle" parent="MyBaseStyle"> 
    <item name="some_attribute_5">value</item> 
</style> 

私が代わりにこれを書いたかのように、MyOtherStyleは動作します:

<item name="android:textColor" >#000000</item> 
<item name="android:textSize" >25sp</item> 

<style name="MyOtherStyle"> 
    <item name="some_attribute_1">value</item> 
    <item name="some_attribute_2">value</item> 
    <item name="some_attribute_3">value</item> 
    <item name="some_attribute_4">value</item> 
    <item name="some_attribute_5">value</item> 
</style> 

また、あなたはおそらくandroid名前空間を使用するには、これらの2行を変更する必要があります

+0

Pありがとうございましたこの問題を解決しました –

関連する問題