a.ch.
a.ch.

Reputation: 8380

Set minimum size of the Nine-Patch

I'd like to have the Nine-Patch drawable as a background of a view. I want it to downscale when the view size is less than minimum that I specify. On the other hand I want this Nine-Patch drawable to grow as usual when the size of the view is greater than that specified. Here is the illustration of desired drawable behavior:

desired drawable behavior

Is it actually possible to achieve this with Nine-Patch drawables?

Upvotes: 1

Views: 1644

Answers (1)

Dalmas
Dalmas

Reputation: 26547

I'm not sure that you are using nine-patches correctly, I'd rather use an ImageButton with a nine-patch as a background without the star in the center. Then you can use the android:scaleType attribute on your ImageButton to scale your image as you want.

Here is an example (use a separated drawable to show your star on the button) :

 <ImageButton
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:src="@drawable/star"
     android:background="@drawable/nine_patch"
     android:adjustViewBounds="true"
     android:scaleType="fitXY"
     android:layout_weight="1" />

Upvotes: 1

Related Questions