Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android's gradient drawables: poor quality of screenshots in Eclipse

I'm using drawables like the following one for backgrounds with a gradient:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <gradient
        android:startColor="#ffffff"
        android:endColor="#cccccc"
        android:angle="-90"
        android:dither="true" />
</shape>

This results in a banded gradient on the emulator, and when I take a screenshot of the emulator (using Eclipse), the result is even poorer:

enter image description here

Why? And how to solve this problem? It is although I'm using android:dither="true" in the drawables' XML and setting this in the Activity's onCreate():

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

By the way, the blue part is the native action bar and the grey gradients are ListView rows with the background drawable.

like image 257
caw Avatar asked Nov 24 '12 15:11

caw


1 Answers

Just to make sure everyone who reads this question sees the solution:

As davehale23 and Chris Stratton pointed out, the problem is not Eclipse or the app being "photographed". The problem is the Android emulator, which obviously uses a reduced bit depth.

So if one takes screenshots of an app, one should always use a real device.

like image 189
caw Avatar answered Sep 28 '22 08:09

caw