I didn't find any solution regarding this problem in stack overflow that's why I am posting it here. I am creating radio buttons dynamically as follows.
RadioButton rb;
//generating radio buttons
for (int i = 0; i < 5; i++) {
rb = new RadioButton(this);
rb.setText(question.getOptions().get(i));
rb.setTextColor(getResources().getColor(R.color.rbTextColor));
rb.setId(i);
rg.addView(rb);
}
It's working perfectly fine but now I want to change the text size of the text of radio buttons through code which should be something like this an per my poor understanding.
rb.setTextSize(20);
but it's now working because radio button does not have this property. So please help me out how can I change the size of the text of the radio buttons in android?
Any help would be greatly appreciated.
Thanks,
momersaleem
You use text appearance like so:
RadioButton rb;
//generating radio buttons
for (int i = 0; i < 5; i++) {
rb = new RadioButton(context);
rb.setText("");
rb.setTextColor(getResources().getColor(R.color.rbTextColor));
rb.setId(i);
rb.setTextAppearance(context, android.R.style.TextAppearance_Large);
}
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