Android learning-how to fill the color of the Button and implement the rounded corner, androidbutton
Create a new folder bt_shape.xml under drawable, as shown below:
1 <? Xml version = "1.0" encoding = "UTF-8"?> 2 <shape xmlns: android = "http://schemas.android.com/apk/res/android"> 3 4 android: shape = "rectangle"> // shape is used to define shape, there are four shapes (rectangular rectangle | oval | line | circle ring) 5 <solid android: color = "# 00f"/> // solid is used to set the fill shape color 6 <corners // corners is used to create a rounded corner (only used for shape is a rectangle) 7 android: topLeftRadius = "8dip" 8 android: topRightRadius = "8dip" 9 android: bottomLeftRadius = "8dip" 10 android: bottomRightRadius = "8dip"/> 11 </shape>
Use the following in activity_main.xml:
1 <Button2 android: id = "@ + id/button" 3 android: layout_width = "match_parent" 4 android: layout_height = "wrap_content" 5 android: background = "@ drawable/bt_shape" // reference 6 android: text = "OK" 7 android: textColor = "# fff" 8/>
The implementation result is as follows: