Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decrease radio button drawable size?

Tags:

android

I have four radio button.

xml source

<RadioButton
    android:id="@+id/fragBtn1"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:background="@drawable/btn_bg_selector"
    android:button="@null"
    android:drawableTop="@drawable/btn_img_selector" />

btn_img_selector

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/selected_btn" android:gravity="center" android:state_checked="true"/>
    <item android:drawable="@drawable/nonselected_btn" android:gravity="center"/>
</selector>

btn_bg_selector

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/btnPressed" android:state_pressed="true"/>
    <item android:drawable="@color/btnNonPressed"/>
</selector>

But button image is too big.
I want to decrease a button image size only..(not decrease button size)
For example, I want to scale a button image size 30px * 30px.
Is it possible?

like image 434
SaeHyun Kim Avatar asked May 25 '15 11:05

SaeHyun Kim


People also ask

How do I resize a radio button?

You cannot change the size of the radio button. Typically people will design a custom UI element to replace the UI aspect of the checkbox/radiobutton. Clicking it results in a click on the underlying checkbox/radio button.

How to reduce radio button size in android?

you can use scalex and scaley properties , then use translationX and translationY to put it in the radiobutton windows. Show activity on this post. Can't be done, the radio button is a built-in control component and as such its size is fixed.

How do you change drawable size on android?

Once you import svg file into Android Studio project, you are going to see <vector> resource then just change the size as you want by width , height attributes. viewportWidth and viewportHeight is to set size for drawing on virtual canvas.


2 Answers

Sclae the button

<RadioButton
        android:scaleX="0.75"
        android:scaleY="0.75" />
like image 162
Heena Arora Avatar answered Sep 19 '22 23:09

Heena Arora


Finally found the correct solution :

Step 1 : Use your @drawable/selected_btn or @drawable/nonselected_btn as an INSET DRAWABLE .

Step 2 : Provide padding as desirous.

Step 3 : Yuhuuuu !! You've decreased the size of the radio button image.

like image 45
Sarasranglt Avatar answered Sep 17 '22 23:09

Sarasranglt