Android uses code to complete color gradient Processing

Source: Internet
Author: User

Android supports color gradient.CodeImplementation, so I will briefly introduce the implementation method, which is one of my projects. The color value above is # e8e8e8, and the color value below is # dbdbdb, if you want to achieve a gradient and there is an obvious line at the end of the gradient, you need the color at the gradient end to be a little deeper than dbdbdb,

 

Create a test_gradient.xml file in drawable as follows:

 
<? XML version = "1.0" encoding = "UTF-8"?> <Shape xmlns: Android = "http://schemas.android.com/apk/res/android" Android: Shape = "rectangle"> <gradient Android: angle = "270" Android: endcolor = "# b9b9b9" Android: startcolor = "# e8e8e8"/> </shape>

 

The usage is as follows:

 

 
<Imageview Android: layout_width = "fill_parent" Android: layout_height = "10dip" Android: Background = "@ drawable/test_gradient"/>

 

 

OK, my endcolor is a little deeper than the following color dbdbdb, so there will be an obvious line at the end of the gradient. If you don't want this line, set endcolor to dbdbdb, OK ~. In gradient, angle refers to the angle of gradient color, which is changed to 90,180,270. Let's try the effect on your own. I won't be able.

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.