Draw background image with shape in Android
I have no intention of discovering a good XML layout for drawing background images in Android today! Shape. Using Shape can replace the previous background image search! A picture shows the effect.
This background is drawn using shape. A few lines of code can be done. I personally feel much better than using images.
Create a shape XML
In the drawable folder. Select drawable when creating Android XML. The following figure shows a shape selection.
Gradient is the gradient of the color, and corners is the rounded corner of the edge.
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:startColor="#151F28" android:endColor="#375974" android:angle="90" > </gradient><corners android:bottomLeftRadius="15dp" android:bottomRightRadius="15dp" android:topLeftRadius="15dp" android:topRightRadius="15dp" /></shape>
Introduce this shape in the layout.
Mainly set Android: backgroud
<LinearLayout android:layout_width="800dp" android:layout_height="200dp" android:orientation="horizontal" android:background="@drawable/myshape" android:layout_gravity="center">
Here is a brief introduction. For details, refer to the introduction above in the android SDK.
QQ chat group for Android and other smart machines is recommended: 187651345