Android: dither = "true" does not hold back, what's wrong?

I am trying to get the android to smooth out the background image of activity - so far without success. I do not know what happened.

This is what I did:

The root element of my activity layout is LinearLayout:

<LinearLayout android:id="@+id/AbsoluteLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:gravity="center_horizontal" android:background="@drawable/background_dither"> 

where I added @ drawable / background_dither as the background image. I put the XML file "background_dither.xml" in drawable-hdpi with the following contents:

 <?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/backimg" android:src="@drawable/background" android:dither="true" android:antialias="true" /> 

which refers to the actual background.png image in drawable-hdpi. An image that includes a large color gradient does appear, but with intense color gamut. From what I learned from the SDK, this can be mitigated by using the definition of the proxy file view / above along with android: dither = "true". This, however, has no effect.

What am I missing to work anti-aliasing?

EDIT : Uploaded sources

EDIT2 : After none of the suggested methods helped get rid of the color scheme by reading this blog post from Romain Guy , I had the idea to check if my background has a PNG alpha channel. This is not true. After adding one, the android apparently uses RGB8888, as stated in the message, and the bandwidth (also for 2.2). Still wondering why other methods didn't work.

EDIT3 : you need to make sure that PNG has not only an alpha channel, but also at least one pixel with an alpha value! = FF, otherwise the android build tools will again split this bitmap into an indexed palette without an alpha channel.

+19
android android-layout
Jan 22 '11 at 18:58
source share
5 answers

I got into this problem today too, and found and used your solution: Create a png in Photoshop with a set of transparency AND, having at least one pixel, using alpha. In fact, what I did sets the layer to 99% opacity. Does not affect colors or anything else, and force the Android compiler to leave my png alone.

+23
Apr 7 2018-11-11T00:
source share

Try to put this line

 getWindow().setFormat(PixelFormat.RGBA_8888); 

right after super.onCreate() and see if it helps.

+3
Jan 23 2018-11-11T00:
source share

I also had these problems, I fixed the application of the 9-patch function to the background image.

Hope for this help

+2
Jun 17 '11 at 17:12
source share

Many people having the same problems report that setting setDither (true) on your resource in Java code works when the XML attribute does not work. In this case, if you can get a link to your LinearLayout in the onCreate method, try

linearLayout.getBackground (). SetDither (true).

An alternative could be an attempt to set a different pixel format, as described here:

http://stuffthathappens.com/blog/2010/06/04/android-color-banding/

Good luck

0
Jan 22 2018-11-21T00:
source share

In Android 2.2.1 and below, an error occurs that causes anti-aliasing to be disabled if filtering is enabled. On Android 2.3.3 and 3.0, this problem seems to be fixed. I'm not sure that the same may be true for antialiases, as you included.

0
May 03 '11 at 16:05
source share



All Articles