Rounded corners with layer-list multi-layer overlay effect

Source: Internet
Author: User

During the Android development process, we may make rounded effects come out as shown:

The four corners are rounded corners. It might be easier if you let the UI designer figure it out directly. But we can also do this with the Layer-list multi-layer overlay effect in Android.

We split it into three parts, the first part is the topmost line (which I call the top), the second part is the middle part (the middle part doesn't need rounded corners), the third part is the bottom.

Implementation at the top:

The top is a box with a gray border but no lower border, rounded corners, and a white background. The implementation results are as follows:

<?xml version="1.0"encoding="UTF-8"? ><layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item > <shape> <solid android:color="#FFFFFF"/> <corners android:topleftradius="10DP"android:toprightradius="10DP"Android:bottomrightradius="0.1DP"android:bottomleftradius="0.1DP"/> <stroke android:width="1DP"Android:color="#ffa8abad"/> </shape> </item> <item android:top="1DP"android:left="1DP"android:right="1DP"> <shape> <solid android:color="#FFFFFF"/> <corners android:topleftradius="10DP"android:toprightradius="10DP"Android:bottomrightradius="0.1DP"android:bottomleftradius="0.1DP"/> <stroke android:width="1DP"Android:color="#ffffffff"/> </shape> </item> </layer-list>

The middle part is a white background with no rounded corners, a gray border without a lower border box. The implementation effect is as follows:

<?xml version="1.0"encoding="UTF-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape> <solid android:color="#FFFFFF"/> <Stroke Android:width="1DP"Android:color="#ffa8abad"/> </shape> </item> <Item Android:left="1DP"Android:right="1DP"Android:top="1DP"> <shape> <solid android:color="#FFFFFF"/> <Stroke Android:width="1DP"Android:color="#ffffffff"/> </shape> </item> </layer-list>

The bottom is a box with a bottom fillet, a white background, and a gray border, to achieve the following effect:

<?xml version="1.0"encoding="UTF-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape> <solid android:color="#FFFFFF"/> <corners android:topleftradius="0.1DP"android:toprightradius="0.1DP"Android:bottomrightradius="10DP"android:bottomleftradius="10DP"/> <stroke android:width="1DP"Android:color="#ffa8abad"/> </shape> </item> <item android:top="1DP"Android:bottom="1DP"android:left="1DP"android:right="1DP"> <shape> <solid android:color="#FFFFFF"/> <corners android:topleftradius="0.1DP"android:toprightradius="0.1DP"Android:bottomrightradius="10DP"android:bottomleftradius="10DP"/> <stroke android:width="1DP"Android:color="#ffffffff"/> </shape> </item></layer-list>

Rounded corners with layer-list multi-layer overlay effect

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.