Layouts in your project that need to achieve the following effects
That is, a white background rectangle with rounded corners at the left and right corner, with no rounded corners, and only a light gray color, with only the top and bottom borders.
Of course, cut a. 9 image as a background can also be achieved, but can be implemented in code or as far as possible in code implementation, because the picture is too much one consumes memory, the other also increases the APK size.
This effect can be achieved through layer-lsit, under the Drawable folder to build an XML file, the code is as follows:
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <layer-listxmlns:android= "Http://schemas.android.com/apk/res/android"> 3 <!-- 4 the item in Layer-list is superimposed from bottom to top, that is, the item defined first is below, followed by stacking it in order .5 - 6 <!--this defines a rectangle with rounded corners below, without rounded corners, with a border color of @color/line_color -7 <Item> 8 <Shape> 9 <CornersAndroid:bottomleftradius= "5DP" Ten Android:bottomrightradius= "5DP" /> One <StrokeAndroid:width= "1px"Android:color= "@color/line_color" /> A </Shape> - </Item> - <!-- the this defines a rectangle below with rounded corners, with no rounded corners, and a white background . - This sets the android:right= "1px" android:left= "1px" android:bottom= "1px" Property - android:right= "1px" indicates that the item is indented to the right of 1px - android:left= "1px" means that the item left is indented 1px inside. + android:bottom= "1px" means that the item is under 1PX. - In this way, the left, right, and lower are smaller than the original 1px, this reduced Zhenggang is the top of the item's border left, right, bottom border + top does not shrink, so it overrides the top border of the top item's bounding box. A so this item overlays the effect of a single item with a left, right, and bottom gray border with rounded corners and a white background rectangle with no rounded corners. at - - <ItemAndroid:right= "1px"Android:left= "1px"Android:bottom= "1px"> - <Shape> - <CornersAndroid:bottomleftradius= "5DP" - Android:bottomrightradius= "5DP" /> - <SolidAndroid:color= "@color/white" /> in </Shape> - </Item> to </layer-list>
Layer-lsit's usage notes are also described in more detail.
Then set the background in the view to change drawable.
Layer-list a rounded rectangle that implements only the left, right, and bottom borders