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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With