如何划分屏幕分为三个部分垂直? [英] How to divide screen into three parts vertically?
问题描述
我的屏幕,滚动型
和三个不同的 LinearLayouts
。
I have screen with ScrollView
and three different LinearLayouts
.
一的LinearLayout
包含微调
和第二个包含的ListView
和第三包含两个按钮
(水平)。
One LinearLayout
contains a Spinner
and second contains ListView
and third contains two Buttons
( horizontal ).
我要显示一个包含3 LinearLayouts
始终显示在屏幕的底部,1 的LinearLayout
始终显示在屏幕在上面。在中间部分,我想显示的ListView
的内容。从而使整个屏幕上有没有空格present。
I want to display a screen that contains 3 LinearLayouts
always displayed at bottom of screen and 1 LinearLayout
always displayed on top. In middle part , i want to display ListView
content. So that on whole screen there is no blank space present.
我要创建屏幕具有不同尺寸的多个设备。
I want to create screen for multiple devices which has different sizes.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/backrepeat"
android:orientation="vertical" >
<include
android:id="@+id/include1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
layout="@layout/actionbar" >
</include>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="10dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".2"
android:background="@drawable/rounded_border"
android:orientation="vertical"
android:padding="15dp" >
<TextView
android:id="@+id/tvDiaryData"
style="@style/greenstyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/heading"
android:gravity="center_horizontal"
android:text="@string/tvDiaryData" >
</TextView>
<TextView
android:layout_width="fill_parent"
android:layout_height="10dp"
android:gravity="center_horizontal" >
</TextView>
<Spinner
android:id="@+id/spDiaryAllBooking"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/select_diaryallbooking" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.6"
android:background="@drawable/layerlist"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="5dp" >
<ListView
android:id="@+id/lvDiaryBooking"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="#636466"
android:layout_weight="1"
android:dividerHeight="1dip"
android:scrollbarStyle="outsideOverlay"
android:scrollbarThumbVertical="@drawable/scrollbar_vertical_thumb" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:background="@drawable/rounded_border"
android:orientation="horizontal"
android:padding="10dp" >
<Button
android:id="@+id/btnDiaryBook"
style="@style/greenButton"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:onClick="btnDiaryBook_Click"
android:text="@string/btnBook" >
</Button>
<Button
android:id="@+id/btnDiaryBalance"
style="@style/greenButton"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:onClick="btnDiaryBalance_Click"
android:text="@string/btnDiaryBalance" >
</Button>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
屏幕布局与我想要的:
Screen Layout with what I want:
推荐答案
这是一个非常简单的解决方案。您应该能够使用这个在当前布局。
This is a very simple solution. You should be able to use this in your current layout.
只是填充 LinearLayouts
您所需的内容。
Just populate the LinearLayouts
with your desired contents.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/ll1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
</LinearLayout>
<LinearLayout
android:id="@+id/ll2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
</LinearLayout>
<LinearLayout
android:id="@+id/ll3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
</LinearLayout>
</LinearLayout>
截屏的code上面贴有颜色显示不同的布局区域。
Screen shot of the code posted above with colors showing the different layout areas.
这篇关于如何划分屏幕分为三个部分垂直?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!