Search code examples
androidnine-patch

Nine-patch image bad quality


in my android app I want to achieve this kind of effect

enter image description here

Thinking about different resolutions and densities I decided to create a nine-patch png file:

enter image description here

When I stretch it it looks quite fine:

enter image description here

But in the android simulator it is blurred

enter image description here

As you can see the quality is bad. Why? What do I have to do to achieve the quality from the first image?


Solution

  • First of all you should provide different 9-patches for ldpi, mdpi, hdpi screens. Then write in manifest file this tag:

    <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:resizeable="true"
        android:smallScreens="true" />
    

    Then android will take appropriate drawable and will not blur it.