I made a custom RadioButton that looks as follow in a Android 5.0 device.
These RadioButtons are dynamic created as shown in the follow methods. So the first method redioButtonPresenterApparence sets its appearance removing circle (setting buttonDrwable to null. The second method set the buttons background later.
private void radioButtonPresenterApparence(RadioButton presenter, int icon) {
Drawable drawable = getResources().getDrawable(icon);
presenter.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
presenter.setButtonDrawable(null);
presenter.setGravity(Gravity.CENTER);
}
private void updateButtonsBackground(){
int childCount = getChildCount();
BackgroundSelector bgSelector = new BackgroundSelector(childCount);
for(int i = 0; i < childCount; i++){
View rb = getChildAt(i);
rb.setBackgroundResource( bgSelector.getBackgroundResource(i) );
rb.requestLayout();
}
requestLayout();
}
My problem is when testing the same on Samsung Android 4.4.4 devices (not sure about other manufactories), it shows as follow.
PS: It's a code created RadioButton. You can check it in the follow method:
private void addPresenter(int icon){
RadioButton presenter = new RadioButton(getContext()); //Create new RadioButton
radioButtonPresenterApparence(presenter, icon); //Set icon and configure aparence
addView(presenter); //Add new button to Selector
presenterParentAparance(presenter); //Config button inside parent
requestLayout(); //Request layout update to Selector
}