2

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>
Trikaldarshiii
  • 11,174
  • 16
  • 67
  • 95
  • You can give `android:layout_height="wrap_content"` for each `RadioButton`. But your question title and the question are a bit different. In your title, you ask about how to decrease the size of **image** displayed, but in your question and code, you don't seem to use any image. Please re-frame your question. – Ghost Mar 17 '12 at 06:23
  • yes i want to decrease size of default image not new image – Trikaldarshiii Mar 17 '12 at 06:25
  • _My question_: Where's the image, mate? – Ghost Mar 17 '12 at 06:26
  • 1
    No.. It;s not possible to change the size of default radio button's image.... If you want you can set your own image to radio button and adjust its size.. that will be the better solution to achieve your goal rather than wasting time to change radio button's image.... – Mohanish Mar 17 '12 at 06:54

5 Answers5

2

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

Community
  • 1
  • 1
Deva
  • 3,919
  • 1
  • 27
  • 38
0

this code work for me!

button.getCompoundDrawables();
compoundDrawables[1].setBounds(10, 10, 90, 90);
aotian16
  • 767
  • 1
  • 10
  • 21
0

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.

Community
  • 1
  • 1
Sarasranglt
  • 3,819
  • 4
  • 23
  • 36
  • Exactly duplicate of @Alish Answere – Trikaldarshiii Feb 25 '16 at 09:18
  • No sir, its different. When you use a custom drawable its a great pain to reduce its size on the radio button. Yes, it doesn't satisfy your need of not using a new image ,but, for any one who has faced difficulty reducing the size of the custom drawable ,just as I did , it works wonderfully well. – Sarasranglt Feb 25 '16 at 09:44
  • And by the way for FYI, @Alish's answer tells you to **reduce the size of the radio button** but what I am talking about is to **reduce the size of image on radio button** – Sarasranglt Feb 25 '16 at 09:47
0

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

0

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

Community
  • 1
  • 1
AliSh
  • 10,085
  • 5
  • 44
  • 76