1 :在drawable里新建一个setbar_bg.xml,代码为

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android/apk/res/android" >
    <!-- 背景色 -->
    <solid android:color="#00000000"/>
    <!-- 边框色 -->
    <stroke android:width="0.5dip" android:color="#f00" />
</shape>

2:在需要的Button里面添加 android:background="@drawable/setbar_bg"

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android/apk/res/android"
    xmlns:app="http://schemas.android/apk/res-auto"
    xmlns:tools="http://schemas.android/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ListActivity"
    android:orientation="vertical"
    >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="结算单列表"
        android:textSize="30sp"
        android:layout_gravity="center"/>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        >
        <Button
            android:layout_width="210dp"
            android:layout_height="wrap_content"
            android:text="未结算"
            android:textSize="25sp"
            android:background="@drawable/setbar_bg"
            android:textColor="#9E131312"
            />
        <Button
            android:layout_width="210dp"
            android:layout_height="wrap_content"
            android:text="已结算"
            android:textSize="25sp"
            android:background="@drawable/setbar_bg"
            android:textColor="#9E131312"
            />


    </LinearLayout>


</LinearLayout>

3:这样就是实现了Button背景颜色的改变

更多推荐

android开发设置Button背景颜色