开发者

Android - ClipDrawable, ScaleDrawable, how does it work?

I'm having quite a problem here and I hope for someone here to able to help me. let's go.

Let's say, I have quite a big image ( 1500x2000 ), i load it as a drawable, fine so far. Now I have a SurfaceView and I want to draw a cert开发者_高级运维ain region ( lets say the top-left-most region ) onto a canvas, in a non-scaled version. I thought using ClipDrawable would be just the right thing to use, but actually, I can't get it to do what I want to. It just displays a scaled-down image with the clip applied.

So basically my question is: how to draw a non-scaled drawable onto a surface, and how to clip that drawable?

any help appreciated, thank you :-)


To clip a drawable simply set the appropriate clip region on the Canvas prior to drawing the drawable. Don't forget to save()/restore() the Canvas!


You can use these in XML Drawable.

Check this doc for more usage for clip and scale label: http://idunnolol.com/android/drawables.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜