按钮背景选择器行为中的不规则

时间:2017-08-02 13:07:26

标签: android android-fragments android-drawable android-radiobutton

在我的申请中,我有很多片段。

片段的顺序如下图所示: enter image description here

App流程从A开始,然后在G中单击前进按钮后,它再次结束于A。

在Fragment F和C的每一个中都有一个包含2个单选按钮的RadioGroup。为了在点击时更改按钮颜色,在这些按钮上实现了选择器drawable。一切顺利,直到流程从A流向G.但是从G到A然后从A移动到F后,单选按钮选择器不能正常工作并且完全显示不同的颜色。我的设备APK版本是Android KITKAT。

单选按钮的代码:

  <RadioGroup
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/quoteEntryRadioGroupMarginTop"
                android:clickable="true"
                android:id="@+id/radioGroupQuotes"
                android:orientation="horizontal">
                <RadioButton
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:padding="@dimen/quoteEntryRadioButtonPadding"
                    android:text="Field Quote Entry"
                    android:textSize="@dimen/quoteEntryTextViewTextSize"
                    android:textColor="#000000"
                    android:button="@android:color/transparent"
                    android:background="@drawable/radiobutton_left_selector"
                    android:id="@+id/radio_FieldQuoteEntry"/>
                <RadioButton
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:padding="@dimen/quoteEntryRadioButtonPadding"
                    android:text="New Quote Entry"
                    android:textSize="@dimen/quoteEntryTextViewTextSize"
                    android:textColor="#F4ED0B"
                    android:button="@android:color/transparent"
                    android:background="@drawable/radiobutton_right_selector"
                    android:id="@+id/radio_NewQuoteEntry"/>
            </RadioGroup>

现在有一个选择器代码:

<?xml version="1.0" encoding="utf-8"?>

<item
    android:drawable="@drawable/radiobutton_left_selected"
    android:state_checked="true" />
<item
    android:drawable="@drawable/radiobutton_left_unselected"
    android:state_checked="false"/>

现在从A到G,这就是我在E中得到的:

enter image description here

但是从G-> A-> B-> E开始,这就是我在E中得到的: enter image description here

如果有什么我错过了,你能告诉我吗? 请帮忙。提前谢谢。

0 个答案:

没有答案