Reputation: 1265
I have a LinearLayout. The button "go" is added with XML:
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView21"
android:layout_marginTop="10dp"
android:background="#0099FF"
android:text="go"
android:textColor="#FFFFFF" />
And the checkboxes dynamically:
for (final String str : strs) {
CheckBox cb = new CheckBox(getApplicationContext());
cb.setText(str);
cb.setTextColor(Color.BLACK);
thisll.addView(cb);
}
Currently elements line up horisontally:
How to make them line up vertically?
Upvotes: 0
Views: 38
Reputation: 1075
Have you tried adding orientation="vertical"
to your LinearLayout?
Eg.
<LinearLayout
android:layout_height="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- The things you want aligned vertically go here -->
</LinearLayout>
Upvotes: 2