【发布时间】:2017-11-19 17:39:27
【问题描述】:
为什么我的按钮颜色没有改变?
<application android:label="Sales Plus" android:icon="@drawable/Icon"
android:theme="@style/AppTheme"></application>
应用主题定义为:
<style name="AppTheme.Base" parent="Theme.AppCompat.Light">
</style>
<!-- inherit from the AppCompat theme -->
<style name="AppTheme" parent="AppTheme.Base">
<!-- Color overrides -->
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<!-- Background Color Override -->
<item name="android:windowBackground">@color/window_background</item>
</style>
创建了一个主题
<style name="ButtonTheme" parent="Widget.AppCompat.Button">
<item name="colorButtonNormal">@color/primary</item>
<item name="colorControlHighlight">@color/accent</item>
</style>
ButtonSM 的样式:
<style name="ButtonSm" parent="Widget.AppCompat.Button.Colored">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
已应用主题:
<Button
android:text="@string/about"
android:id="@+id/btnAbout"
style="@style/ButtonSm"
android:theme="@style/ButtonTheme"
/>
但是,出现的按钮颜色是默认的绿色。 使用 Xamarin.Android.Support.v7.AppCompat 和 Android 框架 7.1 版(API lvl 25)。另外,在 Lollipop 上测试过...
我尝试将 ButtonTheme 父级更改为 ThemeOverlay 以及 Widget.AppCompat.Button.Colored
我已经调查过Coloring Buttons in Android with Material Design and AppCompat
【问题讨论】:
-
@style/ButtonSm 是什么风格?
-
能否请您出示您的风格代码
ButtonSm,我们可以进行测试吗? -
刚刚添加,如果有其他 sn-ps 可以提供帮助,请告诉我。
标签: android xamarin.android android-button