2014年12月24日 星期三

[Android] 在XML設計點擊效果

            <ToggleButton
                android:id="@+id/week1"
                style="@style/geo_fence_week_btn_2"
                android:text="@string/fence_week_1" />

style_custom.xml
      <style name="geo_fence_week_btn_2">
        <item name="android:layout_width">0dp</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_marginRight">2dp</item>
        <item name="android:layout_weight">1</item>
        <item name="android:textColor">@color/geo_fence_week_btn_2_textcolor_selector</item>
        <item name="android:background">@drawable/geo_fence_week_btn_2_bgcolor_selector</item>
    </style>

geo_fence_week_btn_2_bgcolor_selector.xml
    <item android:state_checked="true" android:state_pressed="false">
        <shape android:shape="rectangle">
            <padding android:left="3dp" android:top="3dp" android:right="3dp" android:bottom="3dp"/>
            <solid android:color="#fffcce01"/>
        </shape>
    </item>
    <item android:state_checked="false" android:state_pressed="false">
        <shape android:shape="rectangle">
            <padding android:left="3dp" android:top="3dp" android:right="3dp" android:bottom="3dp"/>
            <solid android:color="#ff939393"/>
        </shape>
    </item>

還不知道要幹嘛
    <item android:state_checked="true" android:state_pressed="true">
        <shape android:shape="rectangle">
            <padding android:left="3dp" android:top="3dp" android:right="3dp" android:bottom="3dp"/>
            <solid android:color="#ffff"/>
        </shape>
    </item>
    <item android:state_checked="false" android:state_pressed="true">
        <shape android:shape="rectangle">
            <padding android:left="3dp" android:top="3dp" android:right="3dp" android:bottom="3dp"/>
            <solid android:color="#ffff"/>
        </shape>
    </item>

沒有留言:

張貼留言