在 API 19 及更低版本上更改 RadioButton 颜色? [英] Changing RadioButton color on API 19 and below?

查看:30
本文介绍了在 API 19 及更低版本上更改 RadioButton 颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个应用程序,用户可以在其中通过从一组 RadioButtons 中进行选择来选择颜色,我使用 ButtonTint XML 属性为按钮着色,但显然这只适用于 API >21/.

So I have an app in which the user can select a color by choosing from a set of RadioButtons, I have used the ButtonTint XML attribute to color the buttons, but obviously this only works on API > 21/.

所以我的问题是,

如何在 KitKat(API 19) 及以下版本上更改 RadioButtons 的颜色?

how to change the color of the RadioButtons on KitKat(API 19) and below?

我已经测试了其他堆栈溢出问题中的一些方法,但到目前为止都没有奏效.

I have tested a few methods from other stack overflow questions, but so far none have worked.

推荐答案

使用设计支持库(23.2.0或最新)appcompatwidgets如下

材料设计前棒棒糖设备:

AppCompat(又名 ActionBarCompat)最初是作为用于在 Gingerbread 上运行的设备的 Android 4.0 ActionBar API,在向后移植的实现之上提供一个公共 API 层和框架实现.AppCompat v21 提供了一个 API 和与 Android 5.0 保持同步的功能集

AppCompat (aka ActionBarCompat) started out as a backport of the Android 4.0 ActionBar API for devices running on Gingerbread, providing a common API layer on top of the backported implementation and the framework implementation. AppCompat v21 delivers an API and feature-set that is up-to-date with Android 5.0

<小时>

Android 支持库 22.1:

使用 AppCompat 时自动为小部件着色的能力是非常有助于保持强大的品牌和一致性在您的应用程序中.这是在膨胀布局时自动完成的- 将 Button 替换为 AppCompatButton,将 TextView 替换为 AppCompatTextView 等,以确保每个都可以支持着色.在在此版本中,那些色彩感知小部件现已公开可用,即使您需要对一个进行子类化,也允许您保持着色支持支持的小部件.

The ability to tint widgets automatically when using AppCompat is incredibly helpful in keeping strong branding and consistency throughout your app. This is done automatically when inflating layouts - replacing Button with AppCompatButton, TextView with AppCompatTextView, etc. to ensure that each could support tinting. In this release, those tint aware widgets are now publicly available, allowing you to keep tinting support even if you need to subclass one of the supported widgets.

此着色感知小部件现已公开可用,即使您需要对受支持的小部件之一进行子类化,也允许您保持着色支持.

This tint aware widgets are now publicly available, allowing you to keep tinting support even if you need to subclass one of the supported widgets.

来自上面的链接,

此时的色调感知小部件的完整列表是:

The full list of tint aware widgets at this time is:

AppCompatAutoCompleteTextView
AppCompatButton
AppCompatCheckBox
AppCompatCheckedTextView
AppCompatEditText
AppCompatMultiAutoCompleteTextView
AppCompatRadioButton
AppCompatRatingBar
AppCompatSpinner
AppCompatTextView

这篇关于在 API 19 及更低版本上更改 RadioButton 颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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