edc*_*598 5 height android scrollview
我试图防止 ScrollView 在屏幕底部占用太多空间,因为它会阻止我的两个按钮显示。我也不想手动设置 ScrollView 的高度。
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
...
android:orientation="horizontal">
<Button .../>
<TextView .../>
<Button .../>
</LinearLayout>
<ScrollView
android:layout_width="math_parent"
android:layout_height="wrap_content">
<ImageView .../>
<ImageView .../>
<ImageView .../>
</ScrollView>
<LinearLayout
...
android:orientation="horizontal">
<Button .../>
<Button .../>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的布局的通用版本。发生的情况是,无论其中有多少项,ScrollView 都会一直延伸到屏幕底部。这会导致屏幕底部的两个按钮不可见。
如果不手动设置 ScrollView 的高度,如何阻止这种情况发生?
我已经使用了android:layout_height="wrap_content"我所有的观点。
这不是应该自动分配视图的高度以适应屏幕的高度吗?
(想包含图片,但我的代表还不够高(-_- ))
我今天解决这个问题的方法是使用RelativeLayout作为基础。将两个LinearLayout分别锚定到 RelLayout 的顶部和底部。然后我会插入,ScrollView但我会确保将其布局属性设置如下:
android:layout_below="topLinearLayout"
android:layout_above="bottomLinearLayout"
| 归档时间: |
|
| 查看次数: |
3339 次 |
| 最近记录: |