简体   繁体   中英

what is equivalent of stretchableImageWithLeftCapWidth (iOS) for Android?

is there any method, property or xml tag for Android to stretch image like iOS?

for example:

UIImage *stretchableBackButton = [[UIImage imageNamed:@"back.png"] stretchableImageWithLeftCapWidth:6 topCapHeight:6];
[button setBackgroundImage:stretchableBackButton forState:UIControlStateNormal];

it stretches the image from 6 px to whole width/height.

thanks...

ok, i found it. it is Nine patch. there is no method or any xml tag. image file must be redrawn by draw9patch tool.

http://developer.android.com/tools/help/draw9patch.html http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch

You can do this code in xml imageView

android:scaleType="fitCenter" android:adjustViewBounds="true"

or you can use through program like this

imageview.setAdjustViewBounds(true);
imageview.setScaleType(ScaleType.FIT_XY);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM