2

我设计了一个活动,其中我有两个单选按钮,但这些大小绰绰有余,我想减小它我使用的文本大小仅减小文本,如果布局大小减小,则仅减小视图而不是单选按钮圆圈

<RadioGroup
        android:id="@+id/RG1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/N"
            android:layout_width="wrap_content"
            android:layout_height="30dip"
            android:text="Yes"
            android:textSize="12dip" />

        <RadioButton
            android:id="@+id/Y"
            android:layout_width="wrap_content"
            android:layout_height="30dip"
            android:checked="true"
            android:text="No"
            android:textSize="12dip" />
    </RadioGroup>
4

5 回答 5

2

为此,您可以使用选择器

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/1" 
    android:state_pressed="true"/>  
<item android:drawable="@drawable/2" 
    android:state_checked="true"/>  
<item android:drawable="@drawable/3" 
    android:state_focused="true" />
<item android:drawable="@drawable/4" />  
</selector> 

在单选按钮标签中,您可以添加

android:button="@drawable/above"
android:layout_height="20dp"
android:layout_width="wrap_content"

希望对您有所帮助。您可能还想看看这个链接

于 2012-03-17T06:45:01.533 回答
0

我认为此链接可能对您有用:Android:如何更改 RadioButton 的大小

您可能会强制使用另一张图片作为背景

于 2012-03-17T06:46:00.330 回答
0

这段代码对我有用!

button.getCompoundDrawables();
compoundDrawables[1].setBounds(10, 10, 90, 90);
于 2015-03-19T13:15:02.783 回答
0

正确的方法是使用自定义可绘制对象作为单选按钮的状态。要减小自定义可绘制对象的图像大小,请检查

于 2016-02-22T10:16:39.223 回答
0

访问此页面http://android-holo-colors.com/,选择 Radio 并下载输出资源(zip 文件包含一个“res”文件夹),其中包含所有可能的单选按钮状态的所有图像,用您的自定义替换图像但保持下载文件的大小。如果您认为它有太多状态,只需从 xml 可绘制主题中的选择器中删除。

在此处输入图像描述

于 2017-06-01T14:40:43.140 回答