安卓:帆布动态更改位图的Z指数位图、帆布、指数、动态

2023-09-07 13:36:31 作者:余生相念

我创建一个Android应用程序,并在我的应用程序我有我画无数位图通过canvas.drawBitmap()函数在画布画布。从我的理解对这些位图的z-index为基础,在它们被画到画布上的顺序设置。绘制这些位图,如果我可以动态改变一个位图的z-index把它推到顶部后,我试图找出是?这似乎是一个很简单的问题,但我有没有运气找到解决办法呢。

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.

在此先感谢, 布罗迪·史密斯

Thanks in advance, Brody Smith

推荐答案

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