Android的按钮textAppearance [英] Android button textAppearance

查看:135
本文介绍了Android的按钮textAppearance的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

这篇关于Android的按钮textAppearance的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆