Как получить z-индекс вида / макета? Или как узнать, на ли это фронте? - PullRequest
1 голос
/ 29 марта 2012

Как получить z-индекс вида / макета?Или как узнать, на ли это фронте?Мне это нужно специально для RelativeLayout

. Я ищу что-то вроде view.getIndex () или view.isOnFront ()

Ответы [ 2 ]

2 голосов
/ 30 марта 2012

Попробуйте это

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..
    }
1 голос
/ 29 марта 2012

Виды будут нарисованы в порядке появления. Итак, первый - это нижний z-индекс, последний - верхний z-индекс

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...