1. 程式人生 > >android設定圓形 帶selector狀態按鈕

android設定圓形 帶selector狀態按鈕

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item  android:state_focused="true"
           android:state_enabled="true"
           android:state_pressed="false">
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="oval">
            <solid android:color="@color/login_btn_press"/>
            <size
                android:width="@dimen/logint_btn_width"
                android:height="@dimen/logint_btn_width"/>

        </shape>
    </item>
    <item android:state_enabled="true"
          android:state_pressed="true" >
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="oval">
            <solid android:color="@color/login_btn_press"/>
            <size
                android:width="@dimen/logint_btn_width"
                android:height="@dimen/logint_btn_width"/>

        </shape>
    </item>
    <item android:state_enabled="true"
          android:state_checked="true">
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="oval">
            <solid android:color="@color/login_btn_press"/>
            <size
                android:width="@dimen/logint_btn_width"
                android:height="@dimen/logint_btn_width"/>

        </shape>
    </item>
    <item android:state_focused="false"
          android:state_enabled="true"
          android:state_pressed="true" >
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="oval">
            <solid android:color="@color/login_btn_press"/>
            <size
                android:width="@dimen/logint_btn_width"
                android:height="@dimen/logint_btn_width"/>

        </shape>
    </item>
    <item android:state_enabled="true" android:state_focused="true"
          android:state_pressed="false">
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="oval">
            <solid android:color="@color/login_btn_press"/>
            <size
                android:width="@dimen/logint_btn_width"
                android:height="@dimen/logint_btn_width"/>

        </shape>
    </item>
    <item android:color="@color/login_btn_normal" >
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="oval">
            <solid android:color="@color/login_btn_normal"/>
            <size
                android:width="@dimen/logint_btn_width"
                android:height="@dimen/logint_btn_width"/>

        </shape>
    </item>
</selector>

如果圖形不hi圓形的,修改

logint_btn_width