As you know the order of views in linear layout is related to the order of them in xml file. Is it possible to change that order with java code by something like indexing?
Asked
Active
Viewed 2.2k times
3 Answers
33
I would try to remove all views with removeView(view)
and add them with addView(childView, index)
in that order you like.

rekire
- 47,260
- 30
- 167
- 264
16
Remove the view, then add it to its new position by calling addView (View child, int index)
, specifying the position at which to add the view.

minipif
- 4,756
- 3
- 30
- 39
2
bringToFront()
may be useful, as it changes the order for order-dependent layouts, too

Dima Karaush
- 93
- 2
- 9
-
Perfect for swapping the order of two elements – gen Jan 21 '23 at 03:58