Android的appcompat-V7:21.0.0变材料的复选框的颜色 [英] Android appcompat-v7:21.0.0 change material checkbox colors

查看:179
本文介绍了Android的appcompat-V7:21.0.0变材料的复选框的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经更新我的项目使用最新appcompat支持库,新版本使用的材料设计复选框和单选按钮。我的应用程序是黑暗的主题和复选框是黑色这是很难看到的。我试图按照保持兼容性但到目前为止,没有任何工程改变自己的颜色。

I've updated my project to use the latest appcompat support library, the new version uses material design checkboxes and radio buttons. My app is dark themed and the checkboxes are black which is hard to see. I'm trying to change their colors according to Maintaining Compatibility but so far nothing works.

RES /价值/ 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'

的Andr​​oidManifest.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,单选按钮等保持黑色。

The checkboxes, editTexts, radiobuttons etc. remain black.

我不知道这使得太大的差别,但单选按钮和复选框我使用的是一个 CheckedTextView ,如下:

I don't know if this makes much difference, but the radiobuttons and checkboxes I'm using are for a CheckedTextView, as following:

单(单选按钮): Android的:机器人:ATTR / listChoiceIndicatorSingle对号=

多(复选框): Android的:机器人:ATTR / listChoiceIndicatorMultiple对号=

由于这些得到黑色材料绘制,我不认为这个问题是由他们来了。

Since these get the black colored material drawable, I don't think the issue is coming from them.

推荐答案

我有一个类似的问题是选中复选框和单选按钮。 我找到了解决办法,当我想通了,需要控制他们的关颜色从

I had a similar problem with unchecked CheckBoxes and RadioButtons. I found the solution, when I figured out that controls takes their "Off" color from

&LT;项目名称=机器人:textColorSecondary&GT; @色/ secondary_text&LT; /项目&GT;

编辑:

指定,如果您的应用程序或活动的主题inherite L的AppCompat(深/浅/ Light.DarkActionBar)之一,您可以设置:

Specifying, if your app's or activity's theme inherite one of L's AppCompat (Dark/Light/Light.DarkActionBar), you can set:

<style name="SampleTheme" parent="Theme.AppCompat">
    <item name="colorAccent">@color/green</item>
    <item name="android:textColorSecondary">@color/red</item>
</style>

这就是结果:

And that's result:

注意::当你得到不同的效果,你可能使用的错误的主题 - 确保你正确设置

Notice: When you get different effect you probably use "wrong" theme - make sure you set it correctly.

这篇关于Android的appcompat-V7:21.0.0变材料的复选框的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆