Draw background images with shape in Android

Source: Internet
Author: User

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

Related Article

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.