Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
335 views
in Technique[技术] by (71.8m points)

android - Widget.AppCompat.Button colorButtonNormal shows gray

I have values:styles.xml with:

<style name="AppTheme.Button" parent="Base.Widget.AppCompat.Button">
    <item name="colorButtonNormal">@color/my_color</item>
    <item name="android:textColor">@android:color/white</item>
</style>

and values-v21:styles.xml with:

<style name="AppTheme.Button" parent="Base.Widget.AppCompat.Button">
      <item name="android:colorButtonNormal">@color/my_color</item>
      <item name="android:textColor">@android:color/white</item>
</style>

And app style with

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
      <item name="android:buttonStyle">@style/AppTheme.Button</item>
</style>

But the colors appears grey instead of @color/my_color

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To customize one button only set android:theme="@style/AppTheme.Button" to your button.

<Button
    android:theme="@style/AppTheme.Button"
    />

Define your style as you did in your question

<style name="AppTheme.Button" parent="Base.Widget.AppCompat.Button">
    <item name="colorButtonNormal">@color/my_color</item>
</style>

[EDIT]

See GitHub demo here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...