Search code examples
androidnine-patch

Android: 9-patch image not stretching as expected


The actual image is this:

the red boxex are where i made 1 px black likes. Even the preview shows fine. So no problem with 9-patch

but the image i get for the following layout is:

<ImageView
    android:id="@+id/image_landing"
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:background="@drawable/loginheader"
    android:contentDescription="@string/login_header"
     />

enter image description here

I Expected, the logo to be on the left and black dots on the right and the rest of the space between them is filled with grey color i selected on the top

Thank You


Solution

  • Is your ImageView really bigger than your 9patch?
    If not, you need to change scaleType as defaut is FIT_CENTER.

    Use android:scaleType="fitXY" or android:adjustViewBounds="true".