9x horizontal zoom

How to create a 9Patch image that scales only horizontally? I do not want it to scale vertically. I can not create such a 9 PNG.

I tried the article http://radleymarx.com/blog/simple-guide-to-9-patch/ , but their method does not work. When I skip the left guide, it gives an error in Eclipse.

I am trying to scale this image horizontally to create a title bar.

+4
source share
3 answers

You can try using cut tiles instead of 9patch:

You create a new xml drawing option using a version of your image other than 9patch, and then set tileMode to repeat. You can then set this new drawable as the background of your header, and it should display as you described.

http://androidblogger.blogspot.com/2009/01/how-to-have-tiled-background-cont.html

+1
source

Well, you can mark vertical scaling as part of a transparent image. May be near the top and bottom edges. Only these parts will scale vertically. The other vertical section will remain the same.

+4
source

Even if this question was answered several years ago, I received a different solution for myself. I tried to have some text images in a vertical LinearLayout, all with the same, but with a variable height (depending on their contents).

My decision:

android:paddingLeft="60dp" android:paddingRight="60dp" 

(If you want your text images to be thinner than adding a higher fill value)

In LinearLayout: android: paddingLeft = "60dp" android: paddingRight = "60dp"

And set its children (text views):

  • 9patch file as backgroud

  • Android: layout_width = "match_parent"

  • Android: layout_height = "wrap_content"

0
source

All Articles