您好,您知道如何在 Android Studio 的应用程序屏幕上将一个对象显示在其他对象之上吗? (java)

Hi, Do you know how to display an object over other objects on the app screen in Android Studio? (java)

例如,我在屏幕上有一个列表,我想要某个动作在屏幕中央弹出一个图像(如对话框),但是当应用程序处于 运行 ,它似乎隐藏在列表后面。你知道是否有一个命令可以使图像出现在屏幕前面(在屏幕上所有其他对象之上)?

您可以使用 View.bringToFront() 或来自视图的父级 ParentView.bringToFront(childView)

函数文档如下:

Change the view's z order in the tree, so it's on top of other sibling views. This ordering change may affect layout, if the parent container uses an order-dependent layout scheme (e.g., LinearLayout). Prior to Build.VERSION_CODES.KITKAT this method should be followed by calls to requestLayout() and invalidate() on the view's parent to force the parent to redraw with the new child ordering.