Canvas 动态更改位图的 z 索引
我正在创建一个 Android 应用程序,在我的应用程序中,我有一个画布,我通过 canvas.drawBitmap () 函数将大量位图绘制到画布上。根据我的理解,这些位图上的 z-index 是根据它们绘制到画布的顺序设置的。我想要弄清楚的是,在绘制这些位图之后,我是否可以动态更改位图上的 z 索引以将其推到顶部?这似乎是一个非常简单的问题,但我还没有找到解决方案。
I am creating an Android app and in my app I have a canvas which I draw numerous bitmaps to the canvas via the canvas.drawBitmap () function. From my understanding the z-index on these bitmaps are set based on the order in which they are being drawn to the canvas. What I am trying to figure out is after drawing these bitmaps if I can dynamically change the z-index on a bitmap to push it to the top? This seems like a very simple problem, but I have had not luck in finding a solution yet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不太可能:调用
drawBitmap
后,位图的内容将渲染到画布上,但画布不存储对原始位图的任何引用,它只存储将位图内容应用到的结果画布。无法动态地说您在 50 个位图中绘制了第一个位图,我希望您将其设为第 50 个位图,并自动重绘其他每个位图以反映更改。因此,您需要提前订购绘图操作。
Not really possible: after you call
drawBitmap
the contents of the bitmap are rendered onto the canvas, but the canvas does not store any references to the original bitmap, it only stores the results of applying the bitmap's contents to the canvas. There is no way to dynamically say that bitmap you drew 1st out of 50, I want you to make that the 50th bitmap and automatically redraw every single other bitmap to reflect the change.So you'll need to order your drawing operations before hand.