Search code examples
androidnine-patch

Why .9.png in Eclipse/device not looks like in draw9patch.exe?


I create combobox_normal_m.9.png in draw9patch.exe. It looks very good in draw9patch.exe, but in Eclipse/device it's not so clear. Why edges are blurred?

from layout:

<Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/selector_cbutton_m" />

from selector:

<item 
    android:drawable="@drawable/combobox_normal_m"
    android:state_selected="false"
    android:state_pressed="false"/>

enter image description hereenter image description here


Solution

  • You've inverted the top and bottom 9 patch data. The top 1 pixel defines the area that can be stretched. The bottom 1 pixel defines the area that can be covered with content. Unless, I guess, you intended there to be a buffer between the right edge of the text and the vertical separator. I could be misunderstanding what you are trying to do.

    You will also notice that you still have to create versions of the 9 patch for different densities if there are non-scalable features that you want to look right at the different pixel densities. In eclipse you are also seeing a enlarged (typically) version of the screen resolution so it may not be representative of the device.