'addview LinearLayout order problems

this is standard addView in a LinearLayout.

            table.addView(child);

enter image description here

but i need to add the view in my layout with this way

enter image description here

Please it is possible to do it??!



Solution 1:[1]

Ascending Order:

parentView.addView(child, 0);

Descending Order:

parentView.addView(child, parentView.getChildCount() - 1);

Solution 2:[2]

Check this out: addView(View view, int position)

Basically you use this method with 0 for "position" and it will insert the view at the front.

Solution 3:[3]

I don't think it is possible to add items to a Vertically oriented LinearLayout, starting from the bottom to the top.

You could use a RelativeLayout, also vertically oriented, then place your first item with gravity=bottom, then place your next items above that item (relatively).

Solution 4:[4]

To better results and control see RecyclerView.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 npace
Solution 3 Booger
Solution 4 Antonio Del Grande