Android - ClipDrawable、ScaleDrawable,它是如何工作的?
我在这里遇到了很大的问题,我希望这里有人能够帮助我。我们走吧。
比方说,我有一个相当大的图像(1500x2000),我将其加载为可绘制的图像,到目前为止还不错。现在我有一个 SurfaceView,我想以非缩放版本将某个区域(比如说最左上角的区域)绘制到画布上。我认为使用 ClipDrawable 是正确的选择,但实际上,我无法让它做我想做的事情。它仅显示应用了剪辑的缩小图像。
所以基本上我的问题是:如何在表面上绘制非缩放的可绘制对象,以及如何剪辑该可绘制对象?
感谢任何帮助,谢谢:-)
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 certain 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 :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 XML Drawable 中使用它们。
检查此文档以了解
clip
和scale
标签的更多用法:http://idunnolol.com/android/drawables.html
You can use these in XML Drawable.
Check this doc for more usage for
clip
andscale
label:http://idunnolol.com/android/drawables.html
要剪辑可绘制对象,只需在绘制可绘制对象之前在画布上设置适当的剪辑区域即可。不要忘记 save()/restore() 画布!
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!