android - Android Material Button没有采用原色
问题描述
关于 Material Button 的文档说:
对于填充按钮,此类使用主题的 ?attr/colorPrimary 作为背景色,使用 ?attr/colorOnPrimary 作为文本颜色。
但 Button 采用 Theme 强调色。这是我的应用主题:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
按钮代码:
<com.google.android.material.button.MaterialButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="Material button">
</com.google.android.material.button.MaterialButton>
颜色.xml:
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B</color>
</resources>
显现:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
我不知道我对文档缺少什么。
解决方案
我对谷歌材料库有同样的问题
implementation 'com.google.android.material:material:1.0.0-alpha1'
我刚刚用这个替换了这个库
implementation 'com.google.android.material:material:1.2.0-alpha02'
推荐阅读
- r - ComplexHeatmap:增加侧面注释的标签大小?
- laravel - Laravel - 从存储/更新帖子中删除图像
- angular - 使用 Angular 在谷歌地图上更改 agm-circle 的颜色
- mysql - 如何只选择最大值?
- discord - Discord.js 机器人无法离开语音频道
- javascript - 我在构造函数中定义的数组在我的任何类方法中都无法读取
- firebase - 数据库何时需要 Firebase 安全规则?
- html - 如何以响应和可扩展的方式浮动和固定背景元素?
- java - Java FileNotFoundException 即使文件存在
- javascript - 为什么 document.getElementsByClassName 除了第一次之外没有准确地获取所有元素?