在pre V21着色复选框 [英] Tinting Checkbox on pre v21

查看:198
本文介绍了在pre V21着色复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我想申请色调来AppCompat复选框。

So, I want to apply tint to AppCompat Checkbox.

一切工作正常的棒棒糖:

Everything works fine on Lollipop:

android:buttonTint="@color/purple_FF4081"

或者是这样的:

or this way:

android:theme="@style/Theme.MyTheme.PurpleAccent"

但将任此PARAMS不更改pre-棒棒糖什么。只有当我设置 colorAccent 的应用程序的主题。但我不希望所有的小部件来改变自己的外表,只有一个复选框。 有没有办法做到这一点不设置彩色可绘制?

But setting any of this params do not change anything on pre-Lollipop. Works only if I set colorAccent for the app theme. But I don't want all widgets to change their look, just one checkbox. Is there any way to do this without setting colored drawables?

推荐答案

简短的回答是:没有。自绘区域将需要对pre-V21设备的使用而创建的。这是因为特殊色彩感知部件当前隐藏,因为他们是一个未完成的实现细节在这个时候(其中谷歌指出,这可能会改变未来的按照常见问题解答部分的开发者博客

The short answer is: no. Custom drawables will need to be created for use on pre-v21 devices. This is because the special tint aware widgets are currently hidden because they're an unfinished implementation detail at this time (which Google states that this may change in the future, according to their developer blog in the FAQ section)

有两种情况,你可以可以覆盖工作colorAccent:

There are two scenarios you could override the colorAccent that may work:

  • 有小部件自己的自定义的版本(即你已经扩展 EditText上)
  • 创建EditText上没有LayoutInflater (即调用新的EditText())。
  • Have your own custom version of the widget (i.e. you’ve extended EditText)
  • Creating the EditText without a LayoutInflater (i.e., calling new EditText()).

这篇关于在pre V21着色复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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