【发布时间】:2020-01-06 18:17:23
【问题描述】:
我有以下布局。我有 FrameLayout(紫红色)填充整个屏幕,在左侧我有 ScrollView(银色)。在 ScrollView 中是带有按钮的 LinearLayout(石灰)。底部按钮上方是 TextView 间隔。我希望它填充垂直空间,以便底部按钮位于屏幕底部。使用滚动视图滚动工作,但间隔不拉伸:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff00ff">
<ScrollView
android:layout_width="134dp"
android:layout_height="match_parent"
android:background="#aaaaaa">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00ff00"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Top" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="3" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="4" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="5" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="6" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="7" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Spacer" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bottom" />
</LinearLayout>
</ScrollView>
</FrameLayout>
如果我删除 ScollView,则间隔会被拉伸,但在横向模式下滚动不起作用:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff00ff">
<LinearLayout
android:layout_width="134dp"
android:layout_height="match_parent"
android:background="#00ff00"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Top" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="3" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="4" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="5" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="6" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="7" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Spacer" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bottom" />
</LinearLayout>
</FrameLayout>
【问题讨论】:
标签: android