Android Note: Change the ProgressBar background color according to the progress code, clipdrawable,layerdrawable,setprogressdrawable

Source: Internet
Author: User


To make a note, the main thing is to use clipdrawable, layerdrawable:

PRIVATE VOID SETPROGRESSBG (int progress)  {    int a =  Progress * 255 / 100;    int color = color.argb (A,  255, 90, 147);    colordrawable colordrawable = new  Colordrawable ();     colordrawable.setcolor (color);     clipdrawable  clipdrawable = new clipdrawable (colordrawable, gravity.left,  Clipdrawable.horizontal);     drawable drawable = getresources (). getDrawable (r.color.transparent);     drawable[] layers = new drawable[]{drawable, Clipdrawable};    layerdrawable layerdrawable = new layerdrawable ( layers);     layerdrawable.setdrawablebylayerid (0,drawable);     Layerdrawable.setdrawablebylayerid (1,clipdrawable);    progressbar.setprogressdrawable (clipdrawable);     Progressbar.setprogress (0);     progressbar.setprogress (progress);     LOGER.D ("Vote vote",  "result = "  + progress);     LOGER.D ("Vote vote",   "a = "  + a);}






This article from the "Sky no traces but I flew" blog, please be sure to keep this source http://glblong.blog.51cto.com/3058613/1739160

Android Note: Change the ProgressBar background color according to the progress code, clipdrawable,layerdrawable,setprogressdrawable

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.