The rounded rectangle effect is achieved by wearing the shape's XML in the Res/drawable directory. The code is as follows:
<?xml version= "1.0" encoding= "Utf-8"? ><shape xmlns:android= "Http://schemas.android.com/apk/res/android" android:shape= "Rectangle" > <corners android:bottomleftradius= "8DP" android: bottomrightradius= "8DP" android:topleftradius= "8DP" android:toprightradius= "8DP"/> <gradient android:angle= "android:centercolor=" #CCFFDD "android:endcolor=" #CCCCCC " android: Startcolor= "#CCCCCC"/> <padding android:bottom= "7DP" android:left= "7DP" android: right= "7DP" android:top= "7DP"/></shape>
Layout file:
<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" match_parent "android:layout_height=" Match_parent "Android:paddi ngbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_horizontal_margin" Android: paddingright= "@dimen/activity_horizontal_margin" android:paddingtop= "@dimen/activity_vertical_margin" tools: Context= ". Mainactivity "> <button android:id=" @+id/button1 "android:layout_width=" 140DP "android:layou t_height= "60DP" android:layout_alignparenttop= "true" android:layout_centerhorizontal= "true" android:b ackground= "@drawable/button" android:text= "set shape"/> <linearlayout android:layout_width= "200DP "Android:layout_height=" 100DP "android:layout_alignparentleft=" true "android:layout_alignparentright = "true" android:layout_below= "@+id/button1" android:layout_margintop= "71DP" <span style= "color: #ff0000;" > android:background= "@drawable/button" </span> android:orientation= "vertical" > </linearlayout> ;</relativelayout>
Implementation of the Android rounded rectangle