Android draws dashed, solid lines, rounded rectangles, half rounded corners

Source: Internet
Author: User

1, draw dashed lines, solid line:

Set up the Dotted_line_gray.xml file below the Drawable folder.

Android:shape= "line" Can change the shape you want

<?xml version= "1.0" encoding= "Utf-8"?>
<shape xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:shape= "Line" >
<!--displays a dashed line, the width of the broken polyline is Dashwith, the gap between the broken lines is dashgap, and when DASHGAP=0DP is solid--
<stroke android:width= "1DP" android:color= "#D5D5D5"
Android:dashwidth= "2DP" android:dashgap= "3DP"/>
<!--dashed height--
<size android:height= "2DP"/>
</shape>

And then in the XML of the layout:
As a background source for ImageView or linearlayout, it is possible.
<linearlayout
Android:id= "@+id/activity_line"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:layout_marginleft= "5dip"
android:layout_marginright= "5dip"
android:background= "@drawable/dotted_line_gray"/>
---------


2. Draw rounded rectangles


Set up the Rect_gray.xml file below the Drawable folder.


<?xml version= "1.0" encoding= "Utf-8"?>
<shape xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:shape= "Rectangle" >
<!--fill Color-
<solid android:color= "#FFFFFF" ></solid>

<!--line width, color gray---
<stroke android:width= "1DP" android:color= "#D5D5D5" ></stroke>

<!--corner radius of a rectangle--
<corners android:radius= "0DP"/>

</shape>
And then in the XML of the layout:
As a background source for ImageView or linearlayout, it is possible.
<linearlayout
Android:id= "@+id/activity_myhezu_wantchuzu"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:background= "@drawable/myhezu_dottedline_rect_green"
android:orientation= "Horizontal" >

3. Half rounded corners:

<shape xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:shape= "Rectangle" >
<corners android:topleftradius= "16DP" <!--radius of left corner above--
android:toprightradius= "16DP" <!--radius of the right corner above--
android:bottomleftradius= "0DP" <!--radius of left rounded corner
android:bottomrightradius= "0DP"/> <!--radius of right corner


<gradient android:startcolor= "#ffffff"
Android:endcolor= "#ffffff"
Android:angle= "/>"


<stroke android:width= "1DP"
Android:color= "#80000000"/>
</shape>

Android draws dashed, solid lines, rounded rectangles, half 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.