How to decrease the size of image displayed on rad

2019-02-19 12:49发布

I have designed an activity in which i have two radio button but those size are more than enough i want to decrease it i am using text size that decreases only text if layout size is decrease that decrease only view not radio button circle

<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>

5条回答
萌系小妹纸
2楼-- · 2019-02-19 13:11

this code work for me!

button.getCompoundDrawables();
compoundDrawables[1].setBounds(10, 10, 90, 90);
查看更多
Evening l夕情丶
3楼-- · 2019-02-19 13:12

visit this page http://android-holo-colors.com/ , select Radio and download the output resources (zip file contains a "res" folder), That contains all images for all posible radio button states, replace images with your custom but keeping the size of the download files. If you think it has too much states simply erase from selector in xml drawable theme.

enter image description here

查看更多
贼婆χ
4楼-- · 2019-02-19 13:19

I think this link may be useful for you : Android: How to change the Size of the RadioButton

You probably force to use another picture as their background

查看更多
放我归山
5楼-- · 2019-02-19 13:20

The correct way is to use your custom drawables for radio button's state. To decrease the image size for custom drawables check THIS out.

查看更多
Evening l夕情丶
6楼-- · 2019-02-19 13:21

For this you can use a Selector

<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> 

and in the radiobutton tag you can add

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

Hope it helpe. You might also want to have a look at this link

查看更多
登录 后发表回答