Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to decrease radio button size in android

can we decrease the size of radio button in android ??

like image 270
user671005 Avatar asked Apr 05 '11 05:04

user671005


1 Answers

If you are using radio button then normally it takes image resource from android-sdk e.g . /android-sdk-macosx/platforms/android-10/data/res/drawable-hdpi

If you want to customize it then take the resource from this folder and resize it (I got it of size 34 x 48 which resized to 19 x 24) Then you can use it Like this:

Here is my radio_button.xml

 <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/btn_radio_on" android:state_checked="true" android:state_pressed="false"/>
    <item android:drawable="@drawable/btn_radio_off" android:state_checked="false" android:state_pressed="false"/>
    <item android:drawable="@drawable/btn_radio_on_pressed" android:state_checked="true" android:state_pressed="true"/>
    <item android:drawable="@drawable/btn_radio_off_pressed" android:state_checked="false" android:state_pressed="true"/>

</selector>

Here is my main.xml

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <RadioGroup
        android:layout_width="fill_parent"
        android:layout_height="30dp"
        android:checkedButton="@+id/first"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/first"
            android:button="@drawable/radio_button"
            android:height="20dp"
            android:width="20dp" />

        <RadioButton
            android:id="@+id/second"
            android:button="@drawable/radio_button"
            android:height="20dp"
            android:width="20dp" />

        <RadioButton
            android:id="@+id/third"
            android:button="@drawable/radio_button"
            android:height="20dp"
            android:width="20dp" />

        <RadioButton
            android:id="@+id/fourth"
            android:button="@drawable/radio_button"
            android:height="20dp"
            android:width="20dp" />
    </RadioGroup>

</LinearLayout>

Due to less reputation I am not able to upload images here so I am giving link for resources and output image.

https://www.dropbox.com/sh/7518zf3onh4su0z/fO7CP7o1EY

like image 126
Avinash Sahu Avatar answered Nov 12 '22 23:11

Avinash Sahu