Gingerbread Gradient

Update
I have a problem with gradient bitmaps on Android 2.3. I read this and decoded my bitmaps using the following options:

BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; options.inDither = true; 
And on android 2.2 everything is great, but on android 2.3 gradient artifacts remain even after that decoding.

I run the application from the article on 2.3 with my bitmaps and all the bad options : 16/32 bit, (not) anti-aliasing and RBG_565, ARGB_8888 and ARGB_4444 - the gradient has artifacts. Also I tried to decode without parameters. Everything is good. Sorry, the problem was

 opts.inScaled=true; opts.inDensity=100; opts.inTargetDensity=800; 

But now I need to get this code to work on Android 2.3, and it still produces a bad gradient (everything is fine on Android 2.2):

  ImageView imageView = (ImageView) tabView.findViewById(R.id.tabsImage); // decode bitmaps BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; options.inDither = true; Bitmap tabImageOn = BitmapFactory.decodeResource(mainActivity.getResources(), tabImageResourceOnId, options); Bitmap tabImageOff = BitmapFactory.decodeResource(mainActivity.getResources(), tabImageResourceOffId, options); // create new selector StateListDrawable tabImage = new StateListDrawable(); tabImage.addState(new int[] { android.R.attr.state_selected }, new BitmapDrawable(mainActivity.getResources(), tabImageOn)); tabImage.addState(new int[] {}, new BitmapDrawable(mainActivity.getResources(), tabImageOff)); tabImage.setDither(true); // set selector to tab imageView.setImageDrawable(tabImage); 
I tried to set window pixel format in onCreate / before / after that method next way:
  WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(getWindow().getAttributes()); lp.format = PixelFormat.RGBA_8888; getWindow().setAttributes(lp); 

But nothing has changed (it’s gingerbread, it uses a 32-bit window format).

Why is this behavior happening and how can I solve my problem?

Thanks. Good afternoon!

+4
source share
1 answer

allowed with moving selected objects to the hdpi folder.

0
source

All Articles