你的确可以用色彩作为改变ImageView的颜色,的方式,但你应该提醒的是,android:tint将总在最前面应用的原始颜色。
的ImageView色调融合了原有的资产色调的颜色。你想要的是色彩完全接管;取而代之的是 在现有颜色上应用色调。因此,例如,如果 源素材资源是黑色的,并且您希望它是#77FFFFFF(半透明的 白色阴影),那么实际上最终会得到白色 的阴影,并在其下面具有黑色背景。
android:tint仅限于ImageView。你想能够在任何视图中着色任何Drawable。
一种可能的替代办法是为你使用Android ColorFilter
彩色滤光器可以用画图来修改每个颜色用该颜料绘制的像素。这是一个不应该直接使用的抽象类。
你可以用ColorFilter做很多或多或少的复杂的事情,但你怎么能应用这个呢?
一个简单的从另一个这样的问题example是:
//White tint
imageView.setColorFilter(Color.argb(255, 255, 255, 255));
or
imageView.setColorFilter(ContextCompat.getColor(context,R.color.COLOR_YOUR_COLOR))
或者一个更完整的答案在这里所以从here
ImageView redCircle = (ImageView) findViewById(R.id.circle_red_imageview);
ImageView greenCircle = (ImageView) findViewById(R.id.circle_green_imageview);
ImageView blueCircle = (ImageView) findViewById(R.id.circle_blue_imageview);
// we can create the color values in different ways:
redCircle.getDrawable().setColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY);
greenCircle.getDrawable().setColorFilter(0xff00ff00, PorterDuff.Mode.MULTIPLY);
blueCircle.getDrawable().setColorFilter(getResources().getColor(R.color.blue), PorterDuff.Mode.MULTIPLY);
您应该检查这些链接,如果你想了解更多