Change android Ripple effect center position for android Appcompat radio button
Asked Answered
R

2

10

I tried to make RTL radio -Put radio on right side- 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 is this:

<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 to change ripple effect center position, because i set button to null, the ripple effect center poisiton is in center of radio button like image above and its not expected by user to see ripple there. i tried to set layout_direction to RTL, but nothing fixed.

I have to mention that i also tried to fix this problem with ripple drawable like below but nothing changed and 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>

Long story short, is there any idea to change android Ripple effect center position for android Appcompat radio button?

Respondence answered 25/4, 2016 at 6:11 Comment(2)
could you find a solution ?Jeopardous
@Jeopardous no, I didn't find any solutionRespondence
B
5

I can succesfully erase the ripple effect by changing the background of the RadioButton to transparent like this:

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

I didn't yet tried but i guess you can set a drawable with left padding to overcome this problem.

Burnley answered 9/8, 2016 at 18:31 Comment(2)
didn't find any solution yet, best answer till now is to remove the ripple effect...Woodford
Appreciate, that attribute helped.Limekiln
L
2

I think what you're looking for is

android:background="?selectableItemBackground"

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

Lacedaemonian answered 21/5, 2019 at 16:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.