Change the center position of the ripple effect effect for android

I tried to make the RTL radio -Put radio station with the right mouse button for Android with AppCompactRadioButton, and I achieved this with android:drawableRight and set android:button="@null" , so my final view is what I wanted, and final code: / p>

 <android.support.v7.widget.AppCompatRadioButton android:id="@+id/radio_man" style="@style/app_font" android:layout_width="0dp" android:layout_height="@dimen/edit_text_height" android:layout_weight="1" android:button="@null" android:drawableRight="@drawable/form_radiobutton" android:minHeight="33dp" android:onClick="onSexRadioButtonClicked" android:text="@string/hint_man" /> 

wrong ripple on radio button

But my question is how to change the central position of the ripple effect, because I set the button to zero, the center of action of the ripple effect is in the center of the radio button, as shown above, and it is not expected from the user to see the ripple there. I tried setting layout_direction to RTL but nothing is fixed.

I should mention that I also tried to fix this problem with ripples as shown below, but nothing has changed and the problem is still there.

 <?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@android:color/transparent"> <item> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/btn_radio_activated" android:state_checked="true" /> <item android:drawable="@drawable/btn_radio_deactive" /> </selector> </item> </ripple> 

In short, is there any idea to change the center position of the Ripple effect effect for the android Appcompat button?

+7
source share
2 answers

I can successfully remove the ripple effect by changing the RadioButton background to transparent, like this:

  android:background="@android:color/transparent" 

I have not tried it yet, but I think you can set drawable with left padding to overcome this problem.

+1
source

I think you are looking

android:background="?selectableItemBackground"

in your RadioButtons. This will overwrite the wrong ripple effect.

0
source

All Articles