Draw background images with shape in android

Source: Internet
Author: User

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.

[Html]
<? 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

[Html]
<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.


From the wanli_smile Column

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.