Under Drawable, create a new folder Bt_shape.xml, as follows:
1<?xml version= "1.0" encoding= "Utf-8"?>2<shape xmlns:android= "Http://schemas.android.com/apk/res/android" >3 4Android:shape= "Rectangle" >//shape for defining shapes with four shapes (rectangularRectangle| Oval Oval | straight Line | round ring) 5<solid android:color= "#00f"/>//solid to set the color of the fill shape6<Corners//corners used to create fillets (only for shapes that are rectangles)7Android:topleftradius= "8dip"8Android:toprightradius= "8dip"9Android:bottomleftradius= "8dip"Tenandroid:bottomrightradius= "8dip"/> One</shape>
For use under 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= "Confirm"7 android:textcolor= "#fff"8 />
The implementation results are as follows:
Android Learning--button fill color and achieve rounded corners