In the Android app development, when setting the button style, in order to reduce the use of images in the layout, we can use the Selectoer selector to replace the image with the shape component in the Android system, which can reduce the size of the app's Sauzain memory.
When the focus is focused: <?xml version= "1.0" encoding= "Utf-8"?>
<shape xmlns:android= "Http://schemas.android.com/apk/res/android" >
<!--set five properties at the same time, the RADIUS attribute is invalid--
<!--set the diameter of 2 corners--
<corners android:radius= "270DP"/>
<!--set the radius of the upper left corner--
<!--<corners android:topleftradius= "20DP"/>--
<!--set the radius of the upper-right corner--
<!--<corners android:toprightradius= "20DP"/>--
<!--set the radius of the lower right corner--
<!--<corners android:bottomleftradius= "20DP"/>--
<!--set the radius of the lower left corner--
<!--<corners android:bottomrightradius= "20DP"/>--
<!--filled Colors--
<!--<solid android:color= "@android: Color/holo_green_light"/>--
<!--gradients If you want to fill with solid, you can't fill the color with a dradient gradient, or you'll get an error.
<gradient
Android:endcolor= "#696969"
Android:gradientradius= "150"
Android:startcolor= "#d6dbdf"
Android:type= "Linear"/>
<!--strokes--
<stroke
android:dashgap= "3DP"
Android:dashwidth= "5DP"
Android:width= "2DP"
Android:color= "#000000"/>
<!--Interval--
<padding
Android:bottom= "10DP"
android:left= "10DP"
android:right= "10DP"
android:top= "10DP"/>
</shape> when releasing the focus:
<?xml version= "1.0" encoding= "Utf-8"?><shape xmlns:android= "Http://schemas.android.com/apk/res/android" >
<!--set five properties at the same time, the RADIUS attribute is invalid--
<!--set the diameter of 2 corners--
<corners android:radius= "270DP"/>
<!--set the radius of the upper left corner--
<!--<corners android:topleftradius= "20DP"/>--
<!--set the radius of the upper-right corner--
<!--<corners android:toprightradius= "20DP"/>--
<!--set the radius of the lower right corner--
<!--<corners android:bottomleftradius= "20DP"/>--
<!--set the radius of the lower left corner--
<!--<corners android:bottomrightradius= "20DP"/>--
<!--filled Colors--
<solid android:color= "@android: Color/holo_red_dark"/>
<!--strokes--
<stroke
android:dashgap= "3DP"
Android:dashwidth= "5DP"
Android:width= "2DP"
Android:color= "#000000"/>
<!--Interval--
<padding
Android:bottom= "10DP"
android:left= "10DP"
android:right= "10DP"
android:top= "10DP"/>
</shape>
Background-selector selector: <?xml version= "1.0" encoding= "Utf-8"?>
<selector xmlns:android= "Http://schemas.android.com/apk/res/android" >
<item android:drawable= "@drawable/te_shape_press" android:state_focused= "true"/>
<item android:drawable= "@drawable/te_shape_press" android:state_pressed= "true"/>
<item android:drawable= "@drawable/te_shape_normal"/>
</selector>
XML layout: <button android:background= "@drawable/btn_select" android:layout_width= "Match_parent" Androi d:layout_height= "Wrap_content" android:layout_margin= "@dimen/activity_horizontal_margin" android:text= "@stri Ng/my_btn "/>
In the Android app development, when setting the button style, in order to reduce the use of images in the layout, we can use the Selectoer selector to replace the image with the shape component in the Android system, which can reduce the size of the app's Sauzain memory.
Android Button Style rounded corners