Как получить z-индекс вида / макета?Или как узнать, на ли это фронте?Мне это нужно специально для RelativeLayout
. Я ищу что-то вроде view.getIndex () или view.isOnFront ()
Попробуйте это
RelativeLayout re=(RelativeLayout) findViewById(R.id.MyRelative); int[] zIndexTab=new int[re.getChildCount()]; for (int i = 0; i < re.getChildCount(); i++) { zIndexTab[i]=re.getChildAt(i).getId(); // zIndexTab[0] will have the Id of the first child in this Layout etc.. // So the first index corresponding to the first view. // The smaller View index will be under the biggest View Index // for example my first View is a button it's index is 0 , the second view is a spinner it's index is 1 // so the spinner will be on the front of the button etc.. }
Виды будут нарисованы в порядке появления. Итак, первый - это нижний z-индекс, последний - верхний z-индекс