Jari
Jari

Reputation: 121

RadioButton in codenameone chaning the checkmark or color style

I am facing problems changing the checkmark on the radiogroup, or color, I appreciate the help I tried the StyleBuilder, changed the font colors, but failed to change the side mark that shows the selected radiobutton

sample enter image description here

thank you,

Upvotes: 2

Views: 45

Answers (1)

Diamond
Diamond

Reputation: 7483

If you have static images, you can change RadioButton icons through constants in your theme.res. The applicable constants are:

radioUnselectedImage
radioUnselectedDisImage
radioSelectedImage
radioSelectedDisImage

If you don't have static images or you want to set the images dynamically in code, you may call below (before your RadioButton declaration):

float sizeMM = 3f;
int size = Display.getInstance().convertToPixels(sizeMM);
int blue = 0x73b5e3;
int white = 0xffffff;

FontImage checkedImage = FontImage.createFixed("" + FontImage.MATERIAL_CHECK, FontImage.getMaterialDesignFont(),
        blue, size, size, 0);
FontImage uncheckedImage = FontImage.createFixed("" + FontImage.MATERIAL_CHECK, FontImage.getMaterialDesignFont(),
        white, size, size, 0);
((DefaultLookAndFeel) UIManager.getInstance().getLookAndFeel())
        .setRadioButtonImages(checkedImage, uncheckedImage, checkedImage, uncheckedImage);
((DefaultLookAndFeel) UIManager.getInstance().getLookAndFeel())
        .setRadioButtonFocusImages(checkedImage, uncheckedImage, checkedImage, uncheckedImage);

Note: DefaultLookAndFeel is deprecated and may cause weird behavior, use it with caution.

Upvotes: 1

Related Questions