且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用"安卓textAppearance"在TextView中/ EditText上会失败,但和QUOT;样式"作品

更新时间:2022-06-02 08:01:58

好吧,看起来像我的错。我做了一个简单的测试:

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"
        />

和样式,text.xml:

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>

关键是要记住,阴影* 元素不是文本属性。正因为如此将不通过textAppearance应用。

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

我要问的Andr​​oid开发者邮件列表上,如果这是期望的行为。

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