Android get all subheadings submissions

I want all children to have a RelativeLayout . I get this with the code:

 aditionView.getAllChildren(). 

But now subviews arrive in the order in which it is added to this view. But I want them to be in ascending order of the position in which it is placed in the view.

+4
source share
1 answer

You can sort the children by View.getLeft ()

 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); logCoordinates(); } private void logCoordinates() { RelativeLayout layout = (RelativeLayout)findViewById(R.id.layout); for (int i = 0; i < layout.getChildCount(); i++) { View child = layout.getChildAt(i); Log.i("tag", String.format("%d %d %d %d", child.getLeft(), child.getTop(), child.getRight(), child.getBottom())); } } @Override public void onWindowFocusChanged(boolean hasFocus) { logCoordinates(); } 

Please compare the log output of logCoordinates() from onCreate() and onWindowFocusChanged() . Coordinate viewing is not available within onCreate() (why?). See the discussion here. How to get the height and width of a button

+9
source

All Articles