23

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?

Mohamad Ghafourian
  • 1,004
  • 1
  • 14
  • 25

2 Answers2

32

I would try to remove all views with removeView(view) and add them with addView(childView, index) in that order you like.

rekire
  • 46,262
  • 29
  • 163
  • 256
15

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,616
  • 3
  • 28
  • 38