如何获取 View /布局的 z-index ?或者如何知道它是否在前面? 我专门需要它用于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..
}
关于android - 如何获取 View /布局的 z-index ?或者如何知道它是否在前面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9928913/