需要为 ImageView 设置色调......我使用它的方式如下:
imageView.setColorFilter(R.color.blue,android.graphics.PorterDuff.Mode.MULTIPLY);
更新 :
@ADev 在他的回答中有更新的解决方案 here ,但他的解决方案需要更新的支持库 - 25.4.0 或更高版本。
您可以通过以下方式在代码中轻松更改色调:imageView.setColorFilter(Color.argb(255, 255, 255, 255));
//白色色调
如果你想要颜色,那么
imageView.setColorFilter(ContextCompat.getColor(context, R.color.COLOR_YOUR_COLOR), android.graphics.PorterDuff.Mode.MULTIPLY);
对于矢量可绘制imageView.setColorFilter(ContextCompat.getColor(context, R.color.COLOR_YOUR_COLOR), android.graphics.PorterDuff.Mode.SRC_IN);
关于android - 如何在android中以编程方式为 ImageView 设置色调?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20121938/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) | Powered by Discuz! X3.4 |