Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trouble shoot 9-patch image problem in android

Tags:

android

I have an ImageView in my layout xml file. I set the width to wrap_content and height to fill_parent. In hierarchy viewer, the width is 2 px and height is 120 px. But when I see it on device, my 9-patch image for the image view does not stretch to 120 px. Can you please tell me how can I trouble shoot this 9 patch image does not stretch error?

Thank you.

like image 578
michael Avatar asked Jun 06 '10 07:06

michael


People also ask

How do I edit a 9 patch image?

Double-click your new NinePatch file to open it in Android Studio. Your workspace will now open. The left pane is your drawing area, in which you can edit the lines for the stretchable patches and content area. The right pane is the preview area, where you can preview your graphic when stretched.

What is 9 patch image in Android?

A 9 patch image is a regular png (. PNG) image which is needful for android app developers where they require to wrap any content within a background image without pixelating the background image.

How is 9 patch image different from a regular bitmap Android?

9 patch images allow you to choose the area of the image that can be scaled and the area that should keep unscaled, unlike the regular images that are scaled along height and width in the same way. It is useful for layouts that can vary greatly in size.


1 Answers

You have to set android:scaleType in order for the ImageView to resize the 9-patch. Normally you will want to set it to fitXY.

like image 191
miguel Avatar answered Sep 28 '22 03:09

miguel