How to put one View over other in RelativLlayout programmatically in Android?

Chimu picture Chimu · May 20, 2013 · Viewed 38.9k times · Source

I am programmatically creating view in Android. Parent layout is RelativLlayout and I'm adding two views in it. First is ListView and second is custom view. I want my second custom view to come on top of the list, but somehow it is getting hidden behind the ListView. How do I make sure that my custom view is on top.

Answer

Megan Scott picture Megan Scott · May 20, 2013

Views get placed in the order you add them to their parent views. The view added last will be on top. You might also want to try View.bringToFront() http://developer.android.com/reference/android/view/View.html#bringToFront()