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