<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView1"
android:layout_alignLeft="@+id/textView1"
android:layout_marginBottom="56dp"
android:text="Button"
android:textColor="#FF0F13"
android:background="@drawable/bbkg"/>//create bbkg.xml in drawable folder
bbkg.xml // nút nền
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/pressed" />
<item android:state_focused="false"
android:drawable="@drawable/normal" />
</selector>
normal.xml // nền nút bình thường tiểu bang
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#10EB0A"/>
<stroke android:width="3dp"
android:color="#0FECFF" />
<padding android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp"/>
<corners android:bottomRightRadius="7dp"
android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp"/>
</shape>
pressed.xml // nền nút bấm bang
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FF1A47"/>
<stroke android:width="3dp"
android:color="#0FECFF"/>
<corners android:bottomRightRadius="7dp"
android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp"/>
</shape>
"Màu nền nút là # 0c0c0c Màu đường viền là # 1a1a1a" - có thể * một * bộ màu, nhưng bạn cần nhiều hơn thế. Nếu chúng ta giả định rằng bạn muốn những màu đó là trạng thái bình thường, màu của bạn cho trạng thái ép là gì? Trạng thái bị vô hiệu hóa? Trạng thái tập trung? Có thể có các trạng thái khác mà nền 'Nút' mặc định xử lý vượt ra ngoài những điều đó, nhưng tôi sẽ bắt đầu với chúng. – CommonsWare