android ui button 点击切换背景与button文字颜色

Android Button点击效果(按钮背景变色、文字变色) – CSDN博客

参考:https://blog.csdn.net/zuiwuyuan/article/details/39561179

效果:

<Button
	android:id="@+id/signin_travel_work_btn"
	style="?android:attr/borderlessButtonStyle"
	android:layout_width="0dp"
	android:layout_height="wrap_content"
	android:layout_marginBottom="@dimen/dimen_10_dip"
	android:layout_marginLeft="@dimen/dimen_8_dip"
	android:layout_marginRight="@dimen/dimen_15_dip"
	android:layout_marginTop="@dimen/dimen_3_dip"
	android:layout_weight="1"
	android:background="@drawable/signin_btn_selector"
	android:text="出差打卡"
	android:textColor="@drawable/signin_tv_selector" />

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="false" android:color="@drawable/bt_message_textcolor1" />
    <item android:state_pressed="true" android:color="@drawable/white" />
</selector>

<drawable name="bt_message_textcolor1">#007aff</drawable>
<drawable name="white">#ffffff</drawable>

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/circular_bead" android:state_pressed="false" />
    <item android:drawable="@drawable/circular_bead_pre" android:state_pressed="true"/>
</selector>

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#007aff" />
</shape>

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#FFFFFF" />

    <stroke
        android:width="0.1dp"
        android:color="@color/black" />

</shape>

 

发表评论

zh_CNChinese
zh_CNChinese