보기/레이아웃의 Z- 색인을 얻는 방법은 무엇입니까? 또는 그것이 앞에 있는지 알아 보는 방법? 내가 찾고 있어요 무엇 RelativeLayout의보기/레이아웃의 Z- 색인을 얻는 방법은 무엇입니까? 또는 그것이 앞에 있는지 알아 보는 방법?
을 위해 특별히 필요 견해는 외관의 순서로 그려집니다()
보기/레이아웃의 Z- 색인을 얻는 방법은 무엇입니까? 또는 그것이 앞에 있는지 알아 보는 방법? 내가 찾고 있어요 무엇 RelativeLayout의보기/레이아웃의 Z- 색인을 얻는 방법은 무엇입니까? 또는 그것이 앞에 있는지 알아 보는 방법?
을 위해 특별히 필요 견해는 외관의 순서로 그려집니다()
view.getIndex() 또는 view.isOnFront 같은입니다. 그래서 첫 번째 바닥 Z- 인덱스, 마지막 최고 Z- 인덱스
입니다 시도 그들은 조작하고이
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..
}
액세스해야하는 두 개의보기가 다른 레이아웃의 일부인 경우 어떻게됩니까 ?? – Taranmeet
순서 변경 때문에. 필요한 것은 view.getIndex() 또는 view.isOnFront()와 같은 것입니다. – znat
indexOfChild를 사용하십시오. –
@stefanbachert 이것은 유익하고 수용 가능한 대답이어야합니다. 감사. –