首页 > 代码库 > android 按钮按下效果(文字颜色和按钮同时变化)

android 按钮按下效果(文字颜色和按钮同时变化)


styles:


<style name="ButtonGreen" parent="@android:style/Widget.Button">
        <item name="android:textSize">18.0sp</item>
        <item name="android:textColor">@drawable/skin_color_button</item>
        <item name="android:background">@drawable/common_btn_green</item>
    </style>



drawable:skin_color_button



<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false" android:color="#ff777777"/>
    <item android:color="#ffffffff"/>
</selector> 

drawable:common_btn_green

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/skin_common_btn_green_pressed" android:state_pressed="true"/>
    <item android:drawable="@drawable/skin_common_btn_green_disable" android:state_enabled="false"/>
    <item android:drawable="@drawable/skin_common_btn_green_normal"/>

</selector>



button:

<Button
            android:id="@+id/reset_btn"
            style="@style/ButtonRed"
            android:layout_width="0.0dip"
            android:layout_height="wrap_content"
            android:layout_margin="15dip"
            android:layout_weight="1"
            android:gravity="center"
            android:text="ceshi" />





android 按钮按下效果(文字颜色和按钮同时变化)