小编Ali*_*ahi的帖子

更改android Appcompat单选按钮的android Ripple效果中心位置

我尝试使用AppCompactRadioButton在右侧按钮上制作RTL电台-Put收音机 - 我实现了这个android:drawableRight并设置android:button="@null"所以我的最终视图是我想要的,最终代码是这样的:

<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" />
Run Code Online (Sandbox Code Playgroud)

单选按钮上出现错误的波纹

但我的问题是如何改变涟漪效应中心位置,因为我将按钮设置为null,涟漪效果中心poisiton位于单选按钮的中心,如上图所示,并且用户不希望看到波纹.我试图将layout_direction设置为RTL,但没有修复.

我不得不提一下,我也尝试用下面的波纹绘制来解决这个问题,但没有任何改变,问题仍然存在.

<?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>
Run Code Online (Sandbox Code Playgroud)

长话短说,有没有想法改变android Appcompat单选按钮的android Ripple效果中心位置?

android radio-button android-appcompat

7
推荐指数
1
解决办法
1132
查看次数

标签 统计

android ×1

android-appcompat ×1

radio-button ×1