【发布时间】:2015-01-06 17:10:08
【问题描述】:
我已更新我的项目以使用最新的 appcompat 支持库,新版本使用材料设计复选框和单选按钮。我的应用程序是深色主题,复选框是黑色的,很难看到。我正在尝试根据Maintaining Compatibility 更改它们的颜色,但到目前为止没有任何效果。
res/values/styles.xml
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
<!-- customize the color palette -->
<item name="colorAccent">@color/silver</item>
</style>
在 build.gradle 中:
android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
}
.....
.....
compile 'com.android.support:appcompat-v7:21.0.0'
AndroidManifest.xml:
<application
android:name="ee.mtakso.App"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppBaseTheme">
复选框、editTexts、单选按钮等保持黑色。
编辑
我不知道这是否有很大不同,但我使用的单选按钮和复选框用于CheckedTextView,如下所示:
单个(单选按钮): android:checkMark="?android:attr/listChoiceIndicatorSingle"
多(复选框): android:checkMark="?android:attr/listChoiceIndicatorMultiple"
由于这些可以绘制黑色材料,我不认为问题出在他们身上。
【问题讨论】:
-
您是否更改了其他 Values 文件夹中的样式,例如 values-v14?
-
您检查的是哪个版本的 android?低于 API 级别 14?或以上?
-
@Arash 不,我已经删除了 values-v14 等,所以这个 styles.xml 是唯一的。
-
@HarshaVardhan 以上,在 4.4.2 上测试
-
我认为这是 appcompat-lib 中的错误。我在 22.1.0 版本中遇到了同样的问题。更新到 22.1.1 后,小部件着色再次起作用。