繁体   English   中英

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

[英]Change android Ripple effect center position for android Appcompat radio button

我尝试使用AppCompactRadioButton制作RTL电台-Put收音机右侧按钮,我用android:drawableRight实现了这个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" />

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

但我的问题是如何改变涟漪效应中心位置,因为我将按钮设置为空,涟漪效果中心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>

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

我可以通过将RadioButton的背景更改为透明来成功擦除涟漪效果,如下所示:

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

我还没试过,但我猜你可以设置一个带左边填充的drawable来克服这个问题。

我想你要找的是

android:background="?selectableItemBackground"

在您的RadioButtons中。 这将覆盖错误的涟漪效应。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM