how to put the text on the left of a radio button in android

Try adding the following attributes into the RadioButton, it should work, this way you still get to keep the ripple effect on the radio button: android:layoutDirection=”rtl” android:textAlignment=”textStart” android:layout_gravity=”start” Remember to set supportsRtl property to true in your application manifest. for eg: <RadioGroup android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”vertical” > <RadioButton android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_margin=”4dp” android:layoutDirection=”rtl” android:textAlignment=”textStart” android:layout_gravity=”start” android:text=”The test … Read more

Android: RadioGroup – How to configure the event listener

This is how you get the checked radiobutton: // This will get the radiogroup RadioGroup rGroup = (RadioGroup)findViewById(r.id.radioGroup1); // This will get the radiobutton in the radiogroup that is checked RadioButton checkedRadioButton = (RadioButton)rGroup.findViewById(rGroup.getCheckedRadioButtonId()); To use the listener, you do this: // This overrides the radiogroup onCheckListener rGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int … Read more

Change the circle color of radio button

It is simpler just setting the buttonTint color (only works on API level 21 or above): <RadioButton android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:id=”@+id/radio” android:checked=”true” android:buttonTint=”@color/your_color”/> In your values/colors.xml file, put your color, in this case a reddish one: <color name=”your_color”>#e75748</color> Result: If you want to do it by code (also API 21 and above): if(Build.VERSION.SDK_INT >= 21) { … Read more

tech