给点击的布局加上背景

来源:互联网 发布:淘宝返利平台哪个好 编辑:程序博客网 时间:2024/05/17 22:36

1.自己任意想要的颜色

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_shortAnimTime">
<item android:drawable="@color/super_light_grey" android:state_focused="true" android:state_pressed="false"/>
<item android:drawable="@color/super_light_grey" android:state_pressed="true"/>
<item android:drawable="@color/white" android:state_focused="false" android:state_pressed="false"/>
<item android:drawable="@color/white"/>

</selector>

1.系统点击的颜色        

只要在代码中加上这句就可以了     style="?android:attr/buttonBarButtonStyle"

例如:

<Button
        android:id="@+id/list_item_card_button_1"
        style="?android:attr/buttonBarButtonStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dip"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:text="是结尾"
        android:textSize="12sp"
        android:textStyle="normal" />






0 0