简体   繁体   中英

android canvas nine patch drawable fails

I'm trying to draw a NinePatchDrawable to a canvas,
but all what i get is a stretched normal drawable:

NinePatchDrawable test = (NinePatchDrawable)getResources().getDrawable(R.drawable.test_orig);
Rect tbounds = new Rect(10, 10, 310, 110);
test.setBounds(tbounds);
test.draw(canvas);

original nine patch:
原始的九个补丁可绘制

what it is supposed to look like:
我要这个

what i get:
我得到什么,但不想要

and before you ask:
yes, I have named the image test_orig.9.png and it is in the right folder.

Remove the lines at the right and the bottom, only keep the top and the left of your current 9-patch image. That should work, hope it helps.

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