Android Custom Graphics shape

Source: Internet
Author: User
Tags custom graphics

In the Android development process, often need to change the default style of the control, then often use a number of pictures to solve. However, this approach may require multiple images, such as a button, a model image to be clicked, and a default style image. This makes it easy to make the apk bigger. Another way is to use a custom graphic to change the style of the control.

The custom shape shape has the following properties

1.solid: Fill

2.gradient: Corresponds to a color gradient. StartColor, EndColor will not say much. Android:angle refers to the angle from which the change begins.

3.stroke: Stroke

4.corners: Rounded Corners

5.padding: Spacing defines how far the content is from the boundary

Implementation steps:

1. Create a My_shape.xml file under the drawable file.

2. Writing style code in the My_shape.xml file

<shape xmlns:android= "Http://schemas.android.com/apk/res/android" >

<solid android:color= "#ffffffff"/>

<corners Android:radius = "10DP"/>

<padding android:bottom= "5DP" android:top= "5DP" android:left= "5DP" android:right= "5DP"/>

<stroke android:width= "1DP" android:color= "#ff00bbe8"/>
</shape>

3. Set Android:[email Protected]/my_shape in the control you are using, or you can set it in the style style file.

As follows:

Android Custom Graphics shape

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.