0

我的背景有问题。在设置带有渐变的背景图像时,我得到了可怕的图像条纹。当我在我的根布局中设置背景时,我这样做如下:

        android:background="@drawable/GradientImage" 

我还尝试在代码中设置我的根布局的背景(从 axml 中删除背景后):

        Window.SetFormat(Android.Graphics.Format.Rgbx8888); 
        Window.AddFlags(Android.Views.WindowManagerFlags.Dither); 

        BitmapFactory.Options options = new BitmapFactory.Options(); 
        options.InPreferredConfig = Bitmap.Config.Argb8888; 
        Bitmap gradient = BitmapFactory.DecodeResource(Resources, Resource.Drawable.Background_640,options); 
        sv.SetBackgroundDrawable(new BitmapDrawable(gradient)); 

这是在 OnCreate 中完成的,不幸的是不能解决问题,

有没有人遇到过这个问题?有谁现在如何解决这个问题。

4

1 回答 1

0

This code works for me (in onCreate())

getWindow().setFormat(PixelFormat.RGBA_8888);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);

Also, when using PNG images, make sure they are using 32-bit color depth,
because some image editing programs save them as 24-bit by default.
For example, in GIMP, you can force the PNG image to be saved as 32-bit
by adding alpha channel.

于 2012-06-27T12:58:04.787 回答