How to customize the color of the CheckMark color in android in a dialog. : android

Kar*_*hik 8 android

How to customize the color of the CheckMark color in android in a dialog. Currently , By default, the color of the checkmark is green by default. I would like to customize it to a different color of choice

Sep*_*phy 6

如果从android系统查看styles.xml,您会看到复选框样式定义如下:

<style name="Widget.CompoundButton.CheckBox">
   <item name="android:background">@android:drawable/btn_check_label_background</item>
   <item name="android:button">@android:drawable/btn_check</item>
</style>
Run Code Online (Sandbox Code Playgroud)

如果你搜索系统的资源,你会发现btn_check是一个可绘制的选择器,有2个状态(开/关),检查颜色是否为绿色.
因此,如果你想拥有自己的颜色可绘制,那么你应该做的是:
- 创建一个styles.xml
- 定义要使用的2个drawables
- 创建支持选择器的xml文件

你可以在android google doc上找到相当详细的完整文档.

  • 请使用此代码编辑您的第一篇文章,这将有助于下一位用户更轻松地找到问题的答案,并且我们还可以使用代码样式更好地展示.你应该添加你的java代码,你的选择器的xml文件,看看是否有什么问题. (2认同)

Kon*_*rov 0

您必须使用修改后的可绘制资源覆盖复选框小部件样式。这是从样式/主题开始的很好的指南http://brainflush.wordpress.com/2009/03/15/understanding-android-themes-and-styles/