Android的XML布局,如何填写内容到整个屏幕,保持完好的注脚? [英] android xml layout, how to fill content to the entire screen, keeping the footer intact?

查看:164
本文介绍了Android的XML布局,如何填写内容到整个屏幕,保持完好的注脚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的XML布局3个主要因素(见图片)

I have 3 main elements in my XML layout (also see the image):


  1. 头,一个的LinearLayout(平平淡淡这里)

  2. 的内容,一个RelativeLayout的,书中有一个形象,我为中心的水平和垂直。

  3. 页脚,一个的LinearLayout

我需要这个样子是如下:

What I need this to look like is as following:


  • 页脚(3)需要所以没有留下空白对齐底部

  • 的含量(2)需要填充头(1)和页脚(3),以使图像之间的空间总是居中precisely两个元件之间。

我已经试过:


  • 设置内容(二)填写垂直,但却忽略了页脚(3),所以因此它不再可见它重叠页脚。

  • 我也试过把页脚(3),填补了底部,然后用重力其他的LinearLayout属性我对齐页脚(3)的底部,这看起来完美的注脚(3),但内容(2)保持它的尺寸(在图像上示出),因为页脚(3)已经填满它下面的空间中。

谁能帮我建立正确的布局?

Can anyone help me with setting up the correct layout?

要回顾一下:
我需要页脚(3)对齐的底部(没有空格),保持头(1)的顶部,并在两者之间应与内容来填充所有的空间(2)的一部分,以便的定心图像看起来正确的。

To recap: I need the footer(3) to be aligned to the bottom (no white space), keep the header(1) at the top, and all the space in between should be filled with the content(2) part so the centering of the image looks right.

如果需要,我可以提供我当前XML的布局code。

I can provide my current XML-Layout code if needed.

推荐答案

尝试这样的..

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:orientation="vertical" >

    </LinearLayout>

    <RelativeLayout
        android:id="@+id/relativeLayout2"
        android:layout_width="wrap_content"
        android:layout_height="200dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/linearLayout1" >

    </RelativeLayout>

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/relativeLayout2"
        android:layout_alignParentBottom="true"
        android:orientation="vertical" >

    </LinearLayout>

</RelativeLayout>

做一个相对布局,因为所有其他3个布局的父布局,并把

make a relative layout as the parent layout of all the 3 other layouts and put

android:layout_below="@+id/relativeLayout2"
        android:layout_alignParentBottom="true"

在最后线性布局

这篇关于Android的XML布局,如何填写内容到整个屏幕,保持完好的注脚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆