Border and gradient, border gradient

Source: Internet
Author: User

Border and gradient, border gradient

 

Demo2 \ aa \ src \ main \ res \ drawable \ bg_border.xml

1 <? Xml version = "1.0" encoding = "UTF-8"?> 2 <shape xmlns: android = "http://schemas.android.com/apk/res/android"> 3 <! -- Set the background color to transparent color --> 4 <solid android: color = "#0000"/> 5 <! -- Set the red border --> 6 <stroke android: width = "4dp" android: color = "# f00"/> 7 </shape>

 

Demo2 \ aa \ src \ main \ res \ drawable \ bg_border2.xml

1 <? Xml version = "1.0" encoding = "UTF-8"?> 2 <shape xmlns: android = "http://schemas.android.com/apk/res/android" 3 android: shape = "rectangle"> 4 <! -- Specify the radius of the four rounded corners of the rounded rectangle --> 5 <corners 6 android: bottomLeftRadius = "5dp" 7 android: bottomRightRadius = "20dp" 8 android: topLeftRadius = "20dp" 9 android: topRightRadius = "5dp"/> 10 <! -- Specify the border line width and color --> 11 <stroke12 android: width = "4dp" 13 android: color = "# f0f"/> 14 <! -- Specifies that the gradient background color is used, and the gradient of the sweep type is used (red, green, and blue) --> 15 <gradient16 android: centerColor = "#0f0" 17 android: endColor = "# 00f" 18 android: startColor = "# f00" 19 android: type = "sweep"/> 20 </shape>

 

Demo2 \ aa \ src \ main \ res \ layout \ activity_main.xml

1 <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" 2 xmlns: tools = "http://schemas.android.com/tools" 3 android: layout_width = "match_parent" 4 android: layout_height = "match_parent" 5 android: orientation = "vertical" 6 tools: context = ". mainActivity "> 7 8 <! -- Specify the background through background --> 9 <TextView10 android: layout_width = "match_parent" 11 android: layout_height = "wrap_content" 12 android: text = "text with border" 13 android: textSize = "24sp" 14 android: background = "@ drawable/bg_border"/> 15 <TextView16 android: layout_width = "match_parent" 17 android: layout_height = "wrap_content" 18 android: text = "rounded border, gradient background text" 19 android: textSize = "24sp" 20 android: background = "@ drawable/bg_border2"/> 21 22 </LinearLayout>

 

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.