帆布动态更改位图的Z指数 [英] Canvas Dynamically change a bitmap's z-index

查看:137
本文介绍了帆布动态更改位图的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.

推荐答案

不是真的有可能:你叫后 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.

这篇关于帆布动态更改位图的Z指数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆