Shape Small Example

Source: Internet
Author: User

The layout is as follows:

Activity_main.xml

1 <Relativelayoutxmlns: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 6     <TextView7         Android:layout_width= "Wrap_content"8 Android:layout_height= "Wrap_content"9 android:layout_centerinparent= "true"Ten Android:background= "@drawable/border_blue" One Android:text= "@string/hello_world" /> A  - </Relativelayout>
Activity_main.xml

Shape

<?XML version= "1.0" encoding= "Utf-8"?><Shapexmlns:android= "Http://schemas.android.com/apk/res/android"Android:shape= "Rectangle" >
<StrokeAndroid:width= "1dip"Android:color= "#ff001CC9" /> <SolidAndroid:color= "#ffffffff" /> <GradientAndroid:angle= "+"Android:endcolor= "#ffffff"Android:startcolor= "#000000" /> <CornersAndroid:radius= "3.0dip" /> <paddingAndroid:bottom= "2.0dip"Android:left= "3.0dip"Android:right= "3.0dip"Android:top= "2.0dip" /></Shape>

Implementation results:

The Android:shape is available in four shapes, respectively:
Rectangle rectangular oval Line linear ring ring.
The Stroke property indicates that the stroke is the bounding box, and you can set the color and width of the border.
The solid property represents a fill within a shape, and you can set the fill color.
The Gradient property represents a gradient within a shape, and you can set the initial night and final color.
Android:angle= "270" represents the gradient angle, must be an integer multiple of 45, the commonly used 0 is a left-to-right gradient, 90 is the bottom-to-top gradient, the corresponding 180 is a right-to-left gradient, 270 is the top-to-bottom gradient, from 0 to 360 (0) counter-clockwise change.
The Corners property represents the arc of the fillet, which is the radian of the four corners of the rectangle in this example, or the radian of each corner individually. such as: Android:topleftradius property.
The Padding property is the fill in each direction.






Shape Small Example

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.