Android rounded border

Source: Internet
Author: User

[From]: http://iaiai.iteye.com/blog/1102958

To set border rounded corners, you can define an XML file in the drawable-mdpi directory:

Java Code
  1. <? XML version ="1.0"Encoding ="UTF-8"?>
  2. <Shape xmlns: Android =Http://schemas.android.com/apk/res/android">
  3. <Solid Android: color ="#000000"/>
  4. <Corners Android: topleftradius ="10dp"
  5. Android: toprightradius ="10dp"
  6. Android: bottomrightradius ="10dp"
  7. Android: bottomleftradius ="10dp"/>
  8. </Shape>

Explanation: solid indicates the fill color. For simplicity, black is used here.
Corners indicates the rounded corner. Note that bottomrightradius is in the lower left rather than the lower right corner, and bottomleftradius is in the lower right corner.
Of course, the above effects can also be set as follows:

Java code
    1. <Corners Android: radius ="5dp"/>


To reference this XML, you only need @ drawable/corners_bg.xml:

Java code
    1. Android: Background ="@ Drawable/corners_bg"

Main. xml:

Java code
  1. <? XML version ="1.0"Encoding ="UTF-8"?>
  2. <Linearlayout xmlns: Android =Http://schemas.android.com/apk/res/android"
  3. Android: Orientation ="Vertical"Android: layout_width ="Fill_parent"
  4. Android: layout_height ="Fill_parent"Android: Background ="# Ffffff">
  5. <Relativelayout Android: Id ="@ + ID/login_div"
  6. Android: layout_width ="Fill_parent"Android: layout_height ="150dip"
  7. Android: padding ="15dip"Android: layout_margin ="15dip"
  8. Android: Background ="@ Drawable/corners_bg">
  9. </Relativelayout>
  10. </Linearlayout>

Running result:

 

Related Article

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.