2

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

正しい方法は、ラジオ ボタンの状態にカスタム ドローアブルを使用することです。カスタム ドローアブルの画像サイズを小さくするには、こちらを確認てください。

于 2016-02-22T10:16:39.223 に答える
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 に答える