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.
Just in case if you want to place a view on top of a ButtonView then use this; android:elevation="7dp" for the view which needs to be placed on top of the button. Thanks. It worked, but also worked with 1dp up for me.
Relativelayout is more effective than Linearlayout. From here: It is a common misconception that using the basic layout structures leads to the most efficient layouts. However, each widget and layout you add to your application requires initialization, layout, and drawing.
Android provides the following ViewGroups or layouts: LinearLayout : is a ViewGroup that aligns all children in a single direction, vertically or horizontally. RelativeLayout : is a ViewGroup that displays child views in relative positions.
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()
Try to use: View.bringToFront();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With