简体   繁体   English

如何使页眉-内容-Android中的页脚布局底部有页脚棒

[英]How to make header - content - footer layout in android with footer stick at bottom

This is my activity layout content: 这是我的活动布局内容:

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

    <RelativeLayout
        android:id="header"
        android:layout_width="fill_parent"
        android:layout_height="50">

        <TextView
            android:layout_width="fill_parent "
            android:layout_height="wrap_content"
            android:text="Header"
            android:textSize="40dp" />
    </RelativeLayout>

    <RelativeLayout
        android:id="main-content"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:text="Content" />

    </RelativeLayout>

    <RelativeLayout
        android:id="footer"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"

        >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Footer"
            android:textSize="40dp" />
    </RelativeLayout>
</RelativeLayout>

The footer is already stick to the bottom, but the content is stick to the top instead of after the "header". 页脚已经固定在底部,但是内容固定在顶部,而不是在“页眉”之后。 I thought about use "Linear Layout" but it's don't have android:layout_alignParentBottom="true" . 我考虑过使用“线性布局”,但没有android:layout_alignParentBottom =“ true” What must I do? 我必须做什么?

Just align the layout of header to parent top. 只需将标题的布局与父顶部对齐即可。 then align the main content below of your header. 然后将标题的主要内容对齐。

Let me edit for you but I will let you to test it.. 让我为您编辑,但让您进行测试。

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

    <RelativeLayout
        android:id="header"
        android:id="@+id/rl_header"
        android:layout_width="fill_parent"
        android:layout_height="50"
        android:layout_alignParentTop="true">

        <TextView
            android:layout_width="fill_parent "
            android:layout_height="wrap_content"
            android:text="Header"
            android:textSize="40dp" />
    </RelativeLayout>

    <RelativeLayout
        android:id="main-content"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/rl_header">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Content" />

    </RelativeLayout>

    <RelativeLayout
        android:id="footer"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"

        >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Footer"
            android:textSize="40dp" />
    </RelativeLayout>
</RelativeLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM