2

How can I decrease the radio button size in android using java code? Its too big.

I'm using the code:

deal = new RadioButton(context);
deal.setHeight(10);
deal.setWidth(5);

which is not effective at all. Please suggest.

user229044
  • 232,980
  • 40
  • 330
  • 338
Khush
  • 867
  • 1
  • 19
  • 46

1 Answers1

2

Are you creating radio button dynamically. Then instead of setting height and width using setheight and setwidth method you can use layoutparams. Set the width and height in layout params...given below is the example of setting parameters of the button..

addQuestion = new Button(NewEmirContext);

addQuestion.setId(134);
addQuestion.setTag("addQuestion");
addQuestion.setBackgroundDrawable(getResources().getDrawable(R.drawable.add_button));
addQuestion.setGravity(Gravity.LEFT);
LinearLayout.LayoutParams addQuestion_Params = 
    new LinearLayout.LayoutParams(24, 24);  
addQuestion_Params.leftMargin=20;
addQuestion.setOnClickListener(mirScreenClickListener);
questionAndAddButtonContainer.addView(addQuestion, addQuestion_Params);
Shivam Kumar
  • 1,892
  • 2
  • 21
  • 33
star angel
  • 520
  • 2
  • 7
  • 14
  • I use the param.topMargin=20; But It has no effect to change the gap between the radio buttons. Anything wrong? thanks. – herbertD Aug 29 '12 at 06:45