Using “android:textAppearance” on TextView/EditText fails, but “style” works

后端 未结 2 610
鱼传尺愫
鱼传尺愫 2020-12-13 05:04

This is a sample TextView in XML, which will properly apply the style TextContactContactName to the TextView.



        
相关标签:
2条回答
  • 2020-12-13 05:36

    I filed a bug report on this issue. I think I got the standard reply "the shadow is not considered part of the text appearance".

    http://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=35887

    0 讨论(0)
  • 2020-12-13 05:37

    Ok, looks like my fault. I had made a quick test:

    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Text styled using 'style'."
            style="@style/UiTestTextView"
            />
    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Text styled using 'textAppearance'."
            android:textAppearance="@style/UiTestTextView"
            />
    

    and the styles-text.xml:

    <style name="UiTestTextView">
        <item name="android:textColor">#ff0000</item>
        <item name="android:textSize">16sp</item>
    
        <item name="android:shadowColor">#ffffff</item>
        <item name="android:shadowDx">1</item>
        <item name="android:shadowDy">2</item>
        <item name="android:shadowRadius">3</item>
    </style>
    

    The key thing is to remember that shadow* elements are not text properties. And as such will not be applied via textAppearance.

    I'm going to ask on the Android Developers Mailing list if this is desired behavior.

    0 讨论(0)
提交回复
热议问题