我正在使用以下drawable:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<gradient
android:startColor="@color/content_background_gradient_start"
android:endColor="@color/content_background_gradient_end"
android:angle="270"
/>
</shape>
Run Code Online (Sandbox Code Playgroud)
问题是我在hdpi设备(如Nexus One和Droid)上出现严重的条带,因为渐变从屏幕顶部到最底部.
根据http://idunnolol.com/android/drawables.html#shape_gradient,渐变没有"抖动"属性.我能做些什么来平滑渐变?
注意:向形状添加dither ="true"似乎不起作用.
我正在尝试在我的活动中放置背景,但图像质量不是预期的.
图像在蓝色条纹上方有一个简单的渐变,目前看起来像这样:

我的活动布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/background_register"
android:drawingCacheQuality="high" >
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
后台描述符(drawable/background_register):
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:antialias="true"
android:dither="true"
android:filter="true"
android:tileMode="repeat"
android:gravity="center"
android:src="@drawable/background_blue_565" />
Run Code Online (Sandbox Code Playgroud)
目前我有一个描述BitmapDrawable的XML文件,它是actitivy的LinearLayout背景.但我已经尝试了迄今为止我发现的一切.启用抖动,抗锯齿,平铺,RGBA_8888模式...您可以命名.有没有人有我可以尝试的不同解决方案或想法?我会非常感激的.
顺便说一句,我目前正在用Galaxy S II开发应用程序.
我遇到了以下问题.当任何位图从资源由冰淇淋三明治运行的应用程序加载时,它可能会被不正确地,如果它已经被解码的格式,这不同于当前窗口的格式,在没有施加抖动呈现.但是,解码格式和窗口格式都已明确设置:
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inPreferredConfig = Bitmap.Config.RGBA_8888;
Run Code Online (Sandbox Code Playgroud)
和
getWindow().setFormat(PixelFormat.RGBA_8888);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);
Run Code Online (Sandbox Code Playgroud)
以下是从使用ICS 4.0.3的仿真器上运行的本文中获取的测试应用程序的屏幕截图(它在HTC HD2上提供相同的结果):
RGBA_8888(32位)窗口格式,各种位图解码格式:

RGB_565(16位)窗口格式,各种位图解码格式:

有几点可以注意到:
RGB_565;RGB_565 窗口格式和RGBA_8888 位图解码格式出现唯一好看的渐变.在这些问题中也报告了这个问题,但仍然没有找到解决方案:
渐变兼容性问题 - ICS默认的颜色比以前的所有Android版本都少
该quistion是,如何处理所有这些格式在ICS,更准确地说,如何使ICS负载与位图RGBA_8888格式,以及如何设置窗口格式RGBA_8888,以便这些位图显示正确?
android ×3
android-4.0-ice-cream-sandwich ×1
background ×1
drawable ×1
gradient ×1
graphics ×1
image ×1