kat*_*tit 2 android android-layout
我想将屏幕分成2个垂直段.底部工具栏应该是固定的 - 假设我想要LinearLayout无论如何都要保持在底部.
最重要的是 - 我希望ScrollView能够长大到工具栏,然后允许滚动.否则 - 它可以完全为空,但工具栏仍然需要在底部.
我怎样才能做到这一点?
一如既往,有几种方法.我会做以下事情
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1">
</ScrollView>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<Button
android:text="Button1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
<Button
android:text="Button2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这使用垂直线性布局并使用wrap_content将按钮放在底部,然后通过赋予ScrollView权重"1"来为ScrollView提供剩余的空间.
| 归档时间: |
|
| 查看次数: |
4434 次 |
| 最近记录: |