Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Color Convert setColorFilter

Tags:

android

colors

I need to use a HTML color code I have in my app.

I am using:

ProgressBar downloadProgressBar = (ProgressBar) findViewById(R.id.downloadprogress);
downloadProgressBar.getIndeterminateDrawable().setColorFilter(
    0xFFFF0000,
    android.graphics.PorterDuff.Mode.MULTIPLY
);

I need to convert a HTML colour code to the format above (like 0xFFFF0000.)

How do I do that? Or is there another solution for using a HTML color code with the above code?

like image 293
user1290717 Avatar asked Mar 31 '14 10:03

user1290717


1 Answers

You can use like:

ProgressBar downloadProgressBar = (ProgressBar)findViewById(R.id.downloadprogress);
downloadProgressBar.getIndeterminateDrawable().setColorFilter(Color.parseColor("#FFFF0000"),android.graphics.PorterDuff.Mode.MULTIPLY);

I think it will help you.
Thank you.

like image 138
Darshak Avatar answered Oct 20 '22 10:10

Darshak