梯度上姜饼 [英] gradient on Gingerbread
问题描述
更新结果
我有一个在Android 2.3梯度位图的一个问题。我读这大文章并德code。使用下一个选项我的位图:
Updated
I have a problem with gradient bitmaps on android 2.3. I read this great article and decode my bitmaps using next options:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
options.inDither = true;
而在Android 2.2一切都很好,但在Android甚至是解码后的2.3梯度文物依然存在。
And on android 2.2 everything is great, but on android 2.3 gradient artifacts remain even after that decoding.
我在2.3与我的位图运行从文章,应用程序和所有变种坏:16/32位,(不)抖动和RBG_565,ARGB_8888和ARGB_4444 - 梯度具有文物。我也试图脱code不带选项。一切正常。对不起,问题是在
I run application from article on 2.3 with my bitmaps and all variants are bad: 16/32 bit, (not) dither and RBG_565, ARGB_8888 and ARGB_4444 - gradient has artifacts. Also I tried to decode without options. Everything is ok. Sorry, problem was in
opts.inScaled=true;
opts.inDensity=100;
opts.inTargetDensity=800;
但是现在我需要做的是Android 2.3这个工作code和它仍然产生不好的梯度(在Android 2.2一切正常):
But now I need to make working this code on android 2.3 and its still produce bad gradient (on android 2.2 everything is ok):
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);
我试图设置窗口像素格式的onCreate
/前/该方法接下来方式后:
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);
但什么也没有改变(这是姜饼,它使用32位窗口格式)。
But nothing has been changed (it's gingerbread, it's using 32 bit window format).
为什么如此行为出现,我怎么能解决我的问题?
Why do so behaviour appear and how can i solve my problem?
感谢。一天好!
推荐答案
与移动可绘制到华电国际
文件夹解决。
solved with moving drawables to hdpi
folder.
这篇关于梯度上姜饼的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!