setColorFilter不会对Android和LT工作; 2.2 [英] setColorFilter doesn't work on Android < 2.2
问题描述
我有一个绘制的setColorFilter法的一个问题。
i have a problem with the setColorFilter-Method on a drawable.
它正常工作在Android 2.2,但不低于版本。
It works fine on Android 2.2 but not on a version lower than that.
我的问题是类似于这里<一个描述是什么href=\"http://stackoverflow.com/questions/5499637/drawable-setcolorfilter-not-working-on-android-2-1\">Drawable.setColorFilter()不工作在Android 2.1 的,但是,这并不为我工作...
My problem is similar to what is described here Drawable.setColorFilter() not working on Android 2.1, but that doesn't work for me...
我用这个code这在Android 2.2,但没有任何东西低于正常工作。
I use this code which works fine on Android 2.2 but not on anything lower than that.
ImageView imageView = (ImageView) findViewById( R.id.imageView1 );
Bitmap immutableBitmap = BitmapFactory.decodeResource( getResources(), R.drawable.mybitmap );
Bitmap mutableBitmap = immutableBitmap.copy( Bitmap.Config.ARGB_8888, true );
immutableBitmap.recycle();
immutableBitmap = null;
Drawable d1 = new BitmapDrawable( mutableBitmap );
d1.setColorFilter( 0xff00ffff, PorterDuff.Mode.MULTIPLY );
imageView.setImageDrawable( d1 );
任何线索得到它的工作是多AP preciated:)
Any clues to get it working are much appreciated :)
推荐答案
我不知道是否有解决这个另一种方式,但我发现,使用 imageView.setBackgroundDrawable()
而不是 imageView.setImageDrawable()
解析针对&lt这一问题; 2.2。
I don't know if there's another way around this, but i found that using imageView.setBackgroundDrawable()
instead of imageView.setImageDrawable()
resolves this issue on < 2.2.
这篇关于setColorFilter不会对Android和LT工作; 2.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!