我有一个LinearLayout。按钮"去"添加了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" />
动态复选框:
for (final String str : strs) {
CheckBox cb = new CheckBox(getApplicationContext());
cb.setText(str);
cb.setTextColor(Color.BLACK);
thisll.addView(cb);
}
如何使它们垂直排列?
答案 0 :(得分:2)
您是否尝试将orientation="vertical"
添加到LinearLayout?
例如
<LinearLayout
android:layout_height="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- The things you want aligned vertically go here -->
</LinearLayout>