In an XML layout that is a RelativeLayout I have a nested LinearLayout. Within this LinearLayout I dynamically add a few TextViews and buttons. My problem is, I can’t get the items to appear under each other like would naturally happen within a LinearLayout. Here is the basic setup:
LinearLayout mobLayout = (LinearLayout) findViewById(R.id.mobButtons);
mobLayout.removeAllViewsInLayout();
I remove all previous junk inside the layout because I reuse it.
mobLayout.addView(mobName);
mobLayout.addView(mobTextHP);
mobLayout.addView(fightButton);
mobLayout.addView(goBackButton);
These should appear one on top of the other, but instead appear all side by side. When I tried adding LinearLayout.LayoutParams to the first one, it wiped everything after it, or pushed it off screen, I couldn’t tell.
Lastly, here is the LinearLayout XML area where these items are added:
<LinearLayout
android:id="@+id/mobButtons"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/fightText">
</LinearLayout>
Thanks in advance!
Use this option for your LinearLayout