Android uses shape to define colors, background colors, border colors for different controls
The right and bottom border color of the set button is red and the border size is 3DP:
Create a new Buttonstyle.xml file in drawable with the following contents:
<?xml version= "1.0" encoding= "UTF-8"?> <layer-list xmlns:android= "Http://schemas.android.com/apk/res /android > <!--box color values--><item> <shape> <solid android:color= "#ff0000"/> </shape> </item> <!--body background color value- <item android:bottom= "3DP" android:right= " 3DP "> <shape> <solid android:color=" #ffffff "/> <padding android:bottom=" 10DP " android:left= "10DP" android:right= "10DP" android:top= "10DP"/ > </shape> </item>
The button inside the layout file is then set as follows:
<button android:id= "@+id/button1" android:layout_width= "Wrap_content" Android:layout_height= "Wrap_content" android:text= "Button1" android:background= "@drawable/buttonstyle"/>
Use of Android shape
Shape is used for setting shapes, can be used in selector,layout and so on, there are 6 sub-tags, the properties are as follows:
<?xml version= "1.0" encoding= "Utf-8"?> <shape xmlns:android= "Http://schemas.android.com/apk/res/android" > <!--rounded Corners--<Corners Android:radius= "9DP"Android:topleftradius= "2DP"Android:toprightradius= "2DP"Android:bottomleftradius= "2DP"Android:bottomrightradius= "2DP"/><!--Set the fillet radius-<!--gradient-<Gradient Android:startcolor= "@android: Color/white"Android:centercolor= "@android: Color/black"Android:endcolor= "@android: Color/black"Android:uselevel= "true"Android:angle= "45"Android:type= "Radial"Android:centerx= "0"Android:centery= "0"Android:gradientradius= "/>" <!--interval--<padding Android:left= "2DP"Android:top= "2DP"Android:right= "2DP"Android:bottom= "2DP"/><!--All directions--<!--size--<size Android:width= "50DP"Android:height= "50DP"/><!--width and height--<!--filled-in <Solid Android:color= "@android: color/white"/><!--filled colors-<!--strokes-<Stroke Android:width= "2DP"Android:color= "@android: Color/black"Android:dashwidth= "1DP"Android:dashgap= "2DP"/> </shape>
Android uses shape to define colors, background colors, border colors for different controls