Defining Z order of views of RelativeLayout in Android

hpique picture hpique · Apr 10, 2010 · Viewed 160.1k times · Source

I would like to define the z order of the views of a RelativeLayout in Android.

I know one way of doing this is calling bringToFront.

Is there are better way of doing this? It would be great if I could define the z order in the layout xml.

Answer

Steve Haley picture Steve Haley · Apr 10, 2010

The easiest way is simply to pay attention to the order in which the Views are added to your XML file. Lower down in the file means higher up in the Z-axis.

Edit: This is documented here and here on the Android developer site. (Thanks @flightplanner)