Set dotted lines, rounded corners, and gradient for Android

Source: Internet
Author: User
Tags change settings

If there is a picture and the truth, let's talk about it first.

Click effect:

Set dotted line:

<? Xml version = "1.0" encoding = "UTF-8"?> <Shape xmlns: android = "http://schemas.android.com/apk/res/android" android: shape = "line"> <stroke android: dashGap = "3dp" android: dashWidth = "6dp" android: width = "1dp" android: color = "#63a219"/> <! -- Height of the dotted line --> <size android: height = "1dp"/> </shape>

The broken line width is dashWith, and the gap width between broken lines is dashGap. When dashGap = 0dp, It is the solid line.

Set rounded corners:

<? 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 = "#63a219"> </stroke> <! -- Radius of the rounded corner of the rectangle --> <corners android: radius = "10dp"/> </shape>

Set gradient fill and four rounded corner radius:

<Shape xmlns: Android = "http://schemas.android.com/apk/res/android" Android: Shape = "rectangle"> <! -- Apply the radius of the Left rounded corner on the top, the radius of the right rounded corner on the top, the radius of the Left rounded corner on the bottom, and the radius of the right rounded corner on the bottom --> <corners Android: topleftradius = "0dp" Android: toprightradius = "7dp" Android: bottomleftradius = "0dp" Android: bottomrightradius = "7dp"/> <! -- Change settings --> <gradient Android: startcolor = "#9cff00" Android: endcolor = "#197600" Android: angle = "270"/> <stroke Android: width = "1dp" Android: color = "#63a219"/> </shape>

Set the gradient click effect:

<style name="list_item_top"><item name="android:clickable">true</item><item name="android:focusable">true</item><item name="android:paddingTop">10dip</item><item name="android:paddingBottom">10dip</item><item name="android:paddingLeft">10dip</item>    <item name="android:paddingRight">10dip</item>    <item name="android:gravity">center_vertical</item>    <item name="android:background">@drawable/background_view_rounded_top</item></style>

<?xml version="1.0" encoding="UTF-8"?><inset xmlns:android="http://schemas.android.com/apk/res/android"    android:insetLeft="1.0px"    android:insetRight="1.0px" >    <selector>        <item android:state_pressed="true">            <shape>                <gradient                    android:angle="270.0"                    android:endColor="@color/base_end_color_pressed"                    android:startColor="@color/base_start_color_pressed" />                <corners                    android:bottomLeftRadius="0.0dip"                    android:bottomRightRadius="0.0dip"                    android:radius="2.0dip"                    android:topLeftRadius="10.0dip"                    android:topRightRadius="10.0dip" />                                <stroke                     android:width="1dp"                     android:color="#eededede" />            </shape>        </item>        <item>            <shape>                <gradient                    android:angle="270.0"                    android:endColor="@color/base_end_color_default"                    android:startColor="@color/base_start_color_default" />                <corners                    android:bottomLeftRadius="0.0dip"                    android:bottomRightRadius="0.0dip"                    android:radius="2.0dip"                    android:topLeftRadius="11.0dip"                    android:topRightRadius="11.0dip" />                                <stroke                     android:width="1dp"                     android:color="#eededede" />            </shape>        </item>    </selector></inset>

Free source code: Free Download

Http://download.csdn.net/detail/lan410812571/5925371

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.