Android change color of ImageView / Bitmap

后端 未结 5 1268
-上瘾入骨i
-上瘾入骨i 2021-02-15 11:19

I need to find a way to change the color of bitmap in Android. I need to replace/change colors of oval image smoothly in my application depending on int value. I ne

5条回答
  •  情歌与酒
    2021-02-15 12:05

    This solution doesn't work very well for me. In some images the final color was wrong. I use this solution instead:

    Drawable myIcon = getResources().getDrawable(R.drawable.your_image); 
    myIcon.setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_ATOP); 
    ((ImageView)findViewById(R.id.view_to_change)).setImageDrawable(myIcon);
    

提交回复
热议问题