slama007
slama007

Reputation: 1293

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??!

Upvotes: 2

Views: 2881

Answers (4)

Antonio Del Grande
Antonio Del Grande

Reputation: 131

To better results and control see RecyclerView.

Upvotes: 0

user1889890
user1889890

Reputation:

Ascending Order:

parentView.addView(child, 0);

Descending Order:

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

Upvotes: 4

Booger
Booger

Reputation: 18725

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).

Upvotes: 0

npace
npace

Reputation: 4258

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.

Upvotes: 1

Related Questions