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

编程入门 行业动态 更新时间:2024-10-27 02:26:35
本文介绍了更改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 strong>如下

Use design support library (23.2.0 OR latest) and appcompatwidgets as below

棒棒糖之前设备的材料设计 :

Material Design for Pre-Lollipop Devices :

AppCompat(aka ActionBarCompat)最初是 Android 4.0 ActionBar API的反向端口,适用于在Gingerbread上运行的设备,在反向移植的实现和框架实现之上提供了一个公共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 :

Android Support Library 22.1 :

在使用AppCompat时自动着色小部件的功能对于保持极为有用。在整个应用中拥有强大的品牌和一致性。当放大布局时,此操作会自动完成-用AppCompatButton替换Button,用AppCompatTextView替换TextView等,以确保每个都支持着色。在此版本的中,这些可感知色的小部件现已公开可用,即使您需要将一个子类化为受支持的小部件,仍可保持着色支持。

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颜色?

本文发布于:2023-11-27 01:29:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636011.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:颜色   版本   API   RadioButton

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!