我正在尝试创建以下屏幕布局:
- 一行包含一些 TextView
- 用户操作将在其中添加或删除 View 的滚动视图
- 纽扣线。
我对 1. 或 3. 没有问题。但是 2. 给我带来了麻烦。我的方案是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainX"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/labels"
android:layout_weight="1">
<!--Some text view of various sizes -->
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/dataScroll">
<LinearLayout
android:id="@+id/dataShow"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/buttons"
android:layout_weight="1">
<!--some buttons-->
</LinearLayout>
</LinearLayout>
当我运行程序时,按钮行位于屏幕中间,当我向屏幕添加元素时(使用 dataShow 布局上的 addView),第一个添加没有问题,但之后我不知道怎么了。
谢谢