更改小部件的颜色. Appcompat 21 [英] Change widgets color. Appcompat 21

查看:76
本文介绍了更改小部件的颜色. Appcompat 21的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用appcompat 21更改特定小部件的颜色?其实我对RadioButton颜色感兴趣.

Is it possible to change color for particular widget with appcompat 21? Actually I'm interested in RadioButton color.

我读到它可以在api 21+上使用.但是,旧的api呢?

I read that it's possible on api 21+. But what about old apis?

推荐答案

如果您使用appcompat-v7(rev 21)并从Theme.Appcompat扩展主题,则RadioButton会自动从扩展主题设置中为颜色*".例如,选中"单选按钮将显示在主题中设置为"colorAccent"的值.

If you use appcompat-v7 (rev 21) and extend your theme from Theme.Appcompat, your RadioButton will automatically get the tinting from your extended theme's settings for "color*". For example, the "checked" radiobutton will show with the "colorAccent" value set in your theme.

我不确定在更高版本的appCompat中是否会更改以下内容(请参见Chris Banes的FAQ中的: https://stackoverflow.com/a/19163987/2259418

I'm not sure if the following will change in a later release of appCompat (see the FAQ from this post by Chris Banes: https://chris.banes.me/2014/10/17/appcompat-v21/), but for now, if you want to set the colors of a radiobutton explicitly, you can still create an appropriate statelistdrawable. This will use whatever colors you set. See the following SO answer for an excellent example of this: https://stackoverflow.com/a/19163987/2259418

这篇关于更改小部件的颜色. Appcompat 21的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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