How to Change image color dynamically in android?

前端 未结 6 825
死守一世寂寞
死守一世寂寞 2020-12-13 12:58

I am doing such type of project ,In my project change Image color dynamically.

I have a one black shape color image ,when user click on this ima

6条回答
  •  情话喂你
    2020-12-13 13:21

    In XML use src not background tag in ImageView. In java code-

    import android.graphics.PorterDuff.Mode;
    final Context context=this;
    
            home1=(ImageView) findViewById(R.id.home1);
     Resources res = context1.getResources();
            final int newColor = res.getColor(android.R.color.black);
            home1.setColorFilter(newColor, Mode.SRC_ATOP);
    

提交回复
热议问题