可绘制形状填充与视图填充?

时间:2019-03-23 00:26:21

标签: android xml

我有一个RadioButton,它使用可绘制的形状作为其背景属性的值:android:background="@drawable/secondary_button"

<RadioButton
        android:text="Male"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" tools:layout_editor_absoluteY="328dp"
        tools:layout_editor_absoluteX="58dp" android:id="@+id/male" android:padding="5dp"
        android:textSize="18dp"
        android:background="@drawable/secondary_button"
        android:button="@null"/>

这是可绘制的文件:

drawable / secondary_button.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true">
        <shape>
            <padding android:bottom="@dimen/secondary_button_padding" />
            <corners
                    android:radius="2dp"/>

            <solid
                    android:color="#00ff00" />
            <stroke android:color="@color/colorGreen" android:width="1dp"/>
            <size android:width="70dp" />
        </shape>
    </item>
    <item>
        <shape>
            <padding android:bottom="@dimen/secondary_button_padding" />
            <corners
                    android:radius="2dp"/>

            <stroke android:color="@color/colorGreen" android:width="1dp"/>
            <size android:width="70dp" />
        </shape>
    </item>
</selector>

RadioButton和可绘制形状都有各自的填充,因此优先级如何?

0 个答案:

没有答案