Resize: Android Radio Button

In my Android app, I have to use a switch. I need to make the switch size small. So I created the same way as this

<item android:state_checked="true" android:drawable="@drawable/btn_check_on" /> <item android:state_checked="false" android:drawable="@drawable/btn_check_off" /> 
  • The normal way the radio button looks

    Image1

  • but with a small icon, it has a space between the text and the button, like this, since the size of the button makes it small

Image2

Does anyone have any ideas on how to avoid the space (Image2) between the text and the button and make it just look like image1.

+6
source share
2 answers

This can be done, but it is not as simple as setting Layout_Width and Layout_height, as with Edit Texts, Buttons, etc. To change the size / appearance of a view, such as a checkbox / radio button, use the "Background" and "Button" properties to specify your own.

but the thistle gives you an idea: http://www.anddev.org/tutorial_change_look_of_checkbox-t4553.html

+6
source

This is done by changing the paddingLeft attribute to RadioButton . The default addition is enough for the button to clear the text, as shown in the first image. I would start with android:paddingLeft="0dp" , which will put the button on top of the text and conduct an experiment from there.

 <RadioButton android:id="@+id/radioButtonHello" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello!" android:paddingLeft="0dp"/> 
+8
source

Source: https://habr.com/ru/post/897276/


All Articles