Android adds a border to various components or layouts in an XML implementation

Source: Internet
Author: User
Tags border color

1, in the Drawable folder to create a new Border.xml file, and then paste the following code, you can define the different color border according to your own needs, or only unilateral, two or three sides, four edges, very good control. 2. Refer to Border.xml on the component you need to use or the layout of layouts in background way. If you need more than one style border in your project, you can, of course, name border.xml a different file name, and then refer to it separately (pull it off, everyone is pretty bull-crossed)!
<?xml version= "1.0" encoding= "UTF-8"? ><layer-list xmlns:android= "http://schemas.android.com/apk/res/ Android >    <!--border color values--    <item>        <shape>            <solid android:color= "#161d26"/ >        </shape>    </item>    <!--The main background color value  in item top and bottom each specify a 1DP border line---    < Item android:top= "1DP" android:bottom= "1DP" android:left= "0DP" android:right= "0DP" >        <shape>            < Solid android:color= "#101419"/>        </shape>        //Can add padding property, which is the fill area of the component's contents from the component's border        <padding Android:bottom= "10DP" android:left= "10DP" android:right= "10DP" android:top= "10DP"/>    </item></ Layer-list>


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.