kiran
kiran

Reputation: 3264

How to add views to LinearLayout, but from bottom upwards?

It is possible to add views to LinearLayout one after another in upward direction?

Upvotes: 16

Views: 26972

Answers (3)

neteinstein
neteinstein

Reputation: 17613

You can add it programmatically with:

LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
layout.addView(newView, index);

You just have to add always with index = 0

Is this the answer to your question?

Upvotes: 28

Howard
Howard

Reputation: 3848

If you want to keep your views top, relativelayout is another choice.

Upvotes: -1

Dinesh Sharma
Dinesh Sharma

Reputation: 11571

If you want to add views to LinearLayout in upward direction(i.e. from bottom to up) use

android:gravity="bottom"

property in the xml of LinearLayout and then add views in the layout. Hope this will solve your problem.

Upvotes: 1

Related Questions