Android Button Style rounded corners

Source: Internet
Author: User



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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.