I have four radio button.
<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" />
<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>
<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?
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.
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.
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.
Sclae the button
<RadioButton
android:scaleX="0.75"
android:scaleY="0.75" />
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With