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



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)?


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.

Answered By – Sillybob

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More