Android的按钮textAppearance按钮、Android、textAppearance

2023-09-08 00:33:41 作者:暗浮

我可以通过这样的内部对象正确设置它改变按钮文本外观:

I can change button text appearance by setting it right within object like this:

<Button
        android:id="@+id/login_btn_bypass"
        android:textSize="15dp"
        android:textColor="#878787"
        android:textStyle="bold" />

但不使用内风格textAppearance时

but not when using textAppearance within style

// in layout xml
<Button
    android:id="@+id/login_btn_login"
    android:textAppearance="@style/login_button_text_appearance" />

// in style definition 
<style name="login_button_text_appearance">
    <item name="android:textSize">15dp</item>
    <item name="android:textColor">#a7a7a7</item>
    <item name="android:textStyle">bold</item>
</style>

有谁知道这是为什么?

anyone knows why?

推荐答案

我认为你应该使用:

风格=@风格/ login_button_text_appearance

而不是

的android:textAppearance =@风格/ login_button_text_appearance

的android:textAppearance 就像任何其他attribut( Android的一个attribut:TEXTSIZE,机器人:TEXTSTYLE 。 ..等),和样式的值并不作为该attribut

the android:textAppearance is just an attribut like any other attribut ( android:textSize,android:textStyle...etc) , and the value of the style is not acceptable as a value for that attribut

编辑:

<Button
    android:id="@+id/login_btn_login"
    style="@style/login_button_text_appearance" />
 
精彩推荐
图片推荐