5

I have been working in android for past few months. The problem for me is now related to Z index value. I am having a layout with a textview,edittext and imageview. Suppose i have a xml file something like this..

 <Layout1>
    <edittext><zindex>3</zindex></edittext>
    <textview><zindex>2</zindex></textview>
    <imageview><zindex>1</zindex></imageview>
 </Layout1>

So my question is that am reading this xml file by DOM parser and i want to set the z index value for all these by the values defined in the xml. Now is there any function or property that i can use to do it. I have learnt about coding it with xml, but that will make it hardcoded. I want a dynamic display so how do i adjust layout with the zindex values.... HELP PLZ

Shalom Craimer
  • 20,659
  • 8
  • 70
  • 106
AMUL
  • 291
  • 1
  • 4
  • 18

2 Answers2

6

there is no Z-index in android layouts. You'll need to use FrameLayout or RelativeLayout if you need to place elements on top of each other in reverse order.

see Placing/Overlapping(z-index) a view above another view in android

Community
  • 1
  • 1
njzk2
  • 38,969
  • 7
  • 69
  • 107
  • Ok thanks man... I wish android could provide something that can help place z index dynamically... – AMUL Dec 20 '11 at 16:23
5

You can use view.setZ(float) starting from API level 21. Here you can find more info.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62