I need to hide a radio button's icon: something like setting it to invisible, but only the icon, not the text (setInvisible
hides also the text). The icon should still take up space, so that the text is aligned with that of the other radio buttons. Also, the radio button (its text) should be clickable.
In other words, what I want is for the icon to be "transparent" (not visible), but otherwise "be there": be clickable, take up space.
I need to do this programmatically, not in XML.
Any ideas?
To label a radio button, add a <label> element after the <input> element and insert a for attribute with the same value as the id of the associated <input> element. Then, write your label text in the <label> tag.
The alternatives to radio buttons are checkboxes and drop down boxes.
XML:
<RadioButton android:paddingLeft="31dp" android:button="@android:color/transparent" />
Java:
RadioButton myButton = (RadioButton) findViewById(R.id.radio); myButton.setButtonDrawable(android.R.color.transparent); myButton.setPadding(31, 0, 0, 0);
setPadding() takes int values that represent Padding in Pixels, see Definition@Google so adjust the Padding as required.
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