网上搜了很多资料,最终使用ScrollView包裹中间部分,代码如下:
<ScrollView android:layout_width="match_parent" android:layout_height="0dp" android:scrollbars="none" android:layout_weight="1">
<LinearLayout
............
</LinearLayout>
<LinearLayout
..............
</ScrollView></LinearLayout>
出现如下问题:
ScrollView can host only one direct child
解决:
主要是ScrollView内部只能有一个子元素,即不能并列两个子元素,所以需要把所有的子元素放到一个LinearLayout内部或RelativeLayout等其他布局方式让后再在这个layout外部用scrollview包住。