简体   繁体   English

Android自定义单选按钮

[英]Android custom radio button

I need to customize a radio button but I'm having terrible difficulties.I need to do it in a way without creating new images (if possible). 我需要自定义一个单选按钮,但是我遇到了很多困难。我需要在没有创建新图像的情况下进行(如果可能的话)。

I was looking at defining shapes instead of png but I can't get it to work. 我正在寻找定义形状而不是png,但我无法让它工作。 Can someone show me how to create and apply shapes and styles? 有人可以告诉我如何创建和应用形状和样式吗?

Here is how I need them to look like: 以下是我需要它们的样子:

在此输入图像描述

I dont think it should be very difficult but I couldn't find a tutorial explaining how shapes work. 我不认为这应该是非常困难的,但我找不到解释形状如何工作的教程。

Use this link select radio style...! 使用此链接选择电台风格......!

http://android-holo-colors.com/ http://android-holo-colors.com/

Save all drawable files,images,style and theme in your project.. 保存项目中的所有可绘制文件,图像,样式和主题。

RadioButton can be customized by customizing application themes or radio button material theme as shown below to change colors of radio button. 可以通过自定义应用程序主题或单选按钮材质主题来自定义RadioButton,如下所示,以更改单选按钮的颜色。 For other customizations see http://www.zoftino.com/android-ui-control-radiobutton 有关其他自定义,请访问http://www.zoftino.com/android-ui-control-radiobutton

<style name="MyRaidoButtonTwo" parent="Widget.AppCompat.CompoundButton.RadioButton">
    <item name="android:colorControlNormal">#64dd17</item>
    <item name="android:colorControlActivated">#460745</item>
    <item name="android:colorControlHighlight">#c51162</item>
    <item name="android:textColorPrimaryDisableOnly">#00838f</item>
    <item name="android:textAppearance">@style/TextAppearance.AppCompat</item>
</style>

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM