How to get the index of particular view OR ViewGroup which is added to the ViewGroup(layout)

Very simple – call the indexOfChild function on the view’s parent:

LinearLayout addNoteLayout = (LinearLayout) findViewById(R.id.llAddNote);
int index = ((ViewGroup) addNoteLayout.getParent()).indexOfChild(addNoteLayout);

Leave a Comment