答案 1
这个问题已经回答了,下面来自@Benito-Bertoli
为单选按钮指定自定义样式:
<style name="MyRadioButtonStyle" parent="@android:style/Widget.CompoundButton.RadioButton">
<item name="android:button">@drawable/custom_btn_radio</item>
</style>
custom_btn_radio.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_window_focused="false"
android:drawable="@drawable/btn_radio_on" />
<item android:state_checked="false" android:state_window_focused="false"
android:drawable="@drawable/btn_radio_off" />
<item android:state_checked="true" android:state_pressed="true"
android:drawable="@drawable/btn_radio_on_pressed" />
<item android:state_checked="false" android:state_pressed="true"
android:drawable="@drawable/btn_radio_off_pressed" />
<item android:state_checked="true" android:state_focused="true"
android:drawable="@drawable/btn_radio_on_selected" />
<item android:state_checked="false" android:state_focused="true"
android:drawable="@drawable/btn_radio_off_selected" />
<item android:state_checked="false" android:drawable="@drawable/btn_radio_off" />
<item android:state_checked="true" android:drawable="@drawable/btn_radio_on" />
</selector>
将可绘制的可绘制对象替换为您自己的可绘制对象。
答案 2
试试这个
<RadioGroup
android:layout_width="wrap_content"
android:orientation="horizontal"
android:layout_height="wrap_content">
<RadioButton
android:button="@null"
android:background="@mipmap/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:button="@null"
android:background="@mipmap/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:button="@null"
android:background="@mipmap/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RadioGroup>
输出:(边距和填充自行)
推荐
-
如何在整个字符串中搜索特定单词? 我有这个代码,它搜索一个字符串数组,如果输入字符串与字符串的第一个字符匹配,则返回结果: 但是我想得到那些字符串,其中输入字符串不仅在第一个字符中匹配,而且在字符串中的任
-
添加Android应用程序的快捷方式到主屏幕打开按钮点击 我想通过按下按钮轻松将我的应用程序添加到主屏幕。因此,我在想的是我的应用程序底部的一个按钮,上面写着“添加到主屏幕”,当按下它时,它会在不关闭应用程序的情况下将快捷方式添
-
将屏幕亮度控制添加到安卓应用程序 我希望在我的应用程序菜单中添加控件以在本地调整屏幕亮度,但似乎不知道如何操作。我已经看到了最大化或调暗亮度的示例,但我希望添加控件,以便用户可以控制和设置亮度级别。有没有
-
-
由以下原因引起:java.lang.IllegalStateException: ParsePlugins 已被初始化 我退出了应用程序,重新启动了它,我得到了一个例外。 编辑: 我想知道为什么Parse会为此抛出一个异常。为什么不继续前进。它已初始化,如果我再次初始化它,那就太大了。 溶液 我已
标签
推荐