android - 更改 API 19 及以下版本的 RadioButton 颜色?

标签 android xml android-studio android-support-library android-support-design

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

所以我的问题是,

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

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

最佳答案

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

Material Design for Pre-Lollipop Devices :

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 Support Library 22.1 :

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.

这种着色感知小部件现在是公开可用的,允许您保持着色支持,即使您需要子类化其中一个受支持的小部件

来自上面的链接,

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

AppCompatAutoCompleteTextView
AppCompatButton
AppCompatCheckBox
AppCompatCheckedTextView
AppCompatEditText
AppCompatMultiAutoCompleteTextView
AppCompatRadioButton
AppCompatRatingBar
AppCompatSpinner
AppCompatTextView

关于android - 更改 API 19 及以下版本的 RadioButton 颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35867231/

相关文章:

java - 如何将 Mat 对象从 java 类传递到 jni cpp。

android - 如何使用 Chrome 自定义选项卡实现 OAuth 单点登录/注销

java - 尝试使用 Intent 登录时出现错误

android - 使用 Canvas.drawText() 定位文本

android - 如何在 android studio 的屏幕中使用回收器 View 和相对布局

javascript - 使用 jquery 解析 RSS 提要的属性

python - 如何将域名应用于按钮?

xml - 为什么创建 'new xml file' 选项不存在?

Android Studio 项目编码默认值

java - 我想在选择安全性并在 Android Studio 中输入密码后为给定的 Wifi SSID 生成二维码