Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set z index by using some integer values

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

like image 930
AMUL Avatar asked Dec 20 '11 14:12

AMUL


2 Answers

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

like image 142
njzk2 Avatar answered Sep 22 '22 20:09

njzk2


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

like image 27
Vadim Kotov Avatar answered Sep 22 '22 20:09

Vadim Kotov