See http://www.bkjia.com/kf/201110/107462.html
In Android, the display effect of default controls is often not very beautiful. We can create an XML file under drawable, which contains the shape label and its related attributes. For example, you can set a LinearLayout border, fill color, and rounded corner effect in this way.
For example, in the following code (today_but_selector.xml ):
<? Xml version = "1.0" encoding = "UTF-8"?>
<Selector xmlns: android = "http://schemas.android.com/apk/res/android">
<Item android: state_pressed = "true">
<Shape>
<! -- Rounded corner -->
<Corners android: radius = "5dp"/>
<Solid android: color = "#888800"/>
</Shape>
</Item>
<Item>
<Shape>
<Solid android: color = "#333333"/>
<Corners android: radius = "5dp"/>
<Padding android: left = "10dp" android: top = "10dp"
Android: right = "10dp" android: bottom = "10dp"/>
</Shape>
</Item>
</Selector>
This xml file can be used as follows. For example, the Button is defined:
<Button android: layout_width = "wrap_content"
Android: layout_height = "wrap_content" android: text = "today"
Android: background = "@ drawable/today_but_selector" android: textColor = "# ffffff"/>
The displayed buttons are as follows:
(1) Under normal circumstances:
(2) Press:
From: yangzhenyu