且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 API 19 及更低版本上更改 RadioButton 颜色?

更新时间:2023-12-04 13:44:10

使用设计支持库(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