androidbuttonstylesappearance

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

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?


Solution

  • I think you should use :

    style = "@style/login_button_text_appearance"
    

    instead of:

    android:textAppearance="@style/login_button_text_appearance"
    

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

    EDIT :

    <Button
        android:id="@+id/login_btn_login"
        style="@style/login_button_text_appearance" />