Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradient compatibility issue - ICS defaults to fewer colors than all the previous versions of Android

2.3.3 left, ICS on right (emulator). Notice the gradient fade effect difference inside the red box.

Gingerbread (2.3.3) emulator left, ICS (4.0.3) emulator right. Notice the gradient fade effect difference inside the red box (open in separate window to see the full sized image).

Mainview background:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/app_bg"
android:orientation="vertical" >

...

</LinearLayout>

app_bg.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#000" android:centerColor="#333"
    android:endColor="#000" android:angle="270" />
</shape>

What is causing this issue? How to fix this, so that the ICS gradient would look as smooth as the 2.3.3 version? Does the problem occur only on emulator?

like image 257
Indrek Kõue Avatar asked Dec 26 '11 13:12

Indrek Kõue


2 Answers

I think the problem is that android is (on the right) drawing the gradient using fewer colours. I believe you want to enable dithering to help disguise the drop in the color depth. Maybe see this answer link

I'm not totally sure how it works, but I believe android will sometimes default to RGB_565 mode, even if the device is capable of 24bit colors.

like image 122
Wozza Avatar answered Nov 14 '22 02:11

Wozza


ICS automaticly adds gradient effect if hardware acceleration is enabled in application. It is also possible to force hardware acceleration for all apps, you will notice that some apps will have gradient background, instead of black.

like image 22
xmRipper Avatar answered Nov 14 '22 02:11

xmRipper