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

For example, I have a list on the screen and I want a certain action to bounce an image in the center of the screen (like a dialog) but the image does not appear when the app is running , it seems to be hiding behind the list. Do you know if there is a command that will cause the image to appear in front of the screen (above all other objects on the screen)?

Answer

You can use View.bringToFront()
or from the view’s parent ParentView.bringToFront(childView)

Here is the function documantion:

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.