Android 安卓:修复空白滚动视图布局?

Android 安卓:修复空白滚动视图布局?,android,android-linearlayout,android-scrollview,android-relativelayout,Android,Android Linearlayout,Android Scrollview,Android Relativelayout,我的目标是在视图顶部显示工具栏,然后是文本视图,然后是滚动视图部分,然后是始终显示在视图底部的页脚。下面仅显示工具栏和TextView标题。ScrollView部分或底部的页脚没有显示任何内容。我错过了什么 EditActivity.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/

我的目标是在视图顶部显示工具栏,然后是文本视图,然后是滚动视图部分,然后是始终显示在视图底部的页脚。下面仅显示工具栏和TextView标题。ScrollView部分或底部的页脚没有显示任何内容。我错过了什么

EditActivity.xml

<RelativeLayout

    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    android:focusableInTouchMode="true"
    tools:context=".EditActivity">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar" >
    </include>

<RelativeLayout android:id="@+id/header"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:layout_below="@+id/toolbar"  >

    <TextView
    android:id="@+id/create_skycard"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textStyle="bold"
    android:textColor="@color/colorFlLabelFinal"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:clickable="false"  />

</RelativeLayout>

<RelativeLayout android:id="@+id/myFooter"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"  >

    <ViewFlipper
        android:id="@+id/viewFlipper1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="5dp"  >

        <include layout="@layout/cardview_nobuttons"
            android:id="@+id/cardviewNobuttons"  />

        <include layout="@layout/cardview_previewbuttons"
            android:id="@+id/cardviewPreviewbuttons" />            

    </ViewFlipper>

</RelativeLayout>  

<ScrollView
android:id="@+id/ScrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/header"
android:layout_above="@+id/myFooter"
android:fillViewport="true"  >

<LinearLayout
    android:id="@+id/LinearLayout1"
    style="@style/scrollbar_shape_style"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"  >      

    <com.wimso.v108.widget.EditText
    ...  />

</LinearLayout>

</ScrollView>

</RelativeLayout>
EditActivity.xml

首先,您应该限制页脚视图的高度。为了进行测试,我将
ViewFlipper
的高度设置为
128dp
,因此您可以根据其内容计算自己的高度

第二:应该为id为
工具栏的
include
设置
android:layout\u alignParentTop=“true”
。要做到这一点,你应该像我一样设置它的高度和重量

第三:
ScrollView
的高度应该是
wrap\u content
而不是
match\u parent
,以确保它在页眉和页脚视图之间延伸

以下是应用上述更正后的布局源代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    android:focusableInTouchMode="true"
    tools:context=".EditActivity">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" />

    <RelativeLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        android:gravity="center_horizontal">

        <TextView
            android:id="@+id/create_skycard"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clickable="false"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="@color/colorFlLabelFinal"
            android:textStyle="bold" />

    </RelativeLayout>

    <ScrollView
        android:id="@+id/ScrollView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/myFooter"
        android:layout_below="@+id/header"
        android:fillViewport="true">

        <LinearLayout
            android:id="@+id/LinearLayout1"
            style="@style/scrollbar_shape_style"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <com.wimso.v108.widget.EditText
            ... />

        </LinearLayout>

    </ScrollView>

    <RelativeLayout
        android:id="@+id/myFooter"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">

        <ViewFlipper
            android:id="@+id/viewFlipper1"
            android:layout_width="match_parent"
            android:layout_height="128dp"
            android:layout_marginBottom="5dp">

            <include
                android:id="@+id/cardviewNobuttons"
                layout="@layout/cardview_nobuttons" />

            <include
                android:id="@+id/cardviewPreviewbuttons"
                layout="@layout/cardview_previewbuttons" />

        </ViewFlipper>

    </RelativeLayout>

</RelativeLayout>


我猜还有另一种方法:您应该创建一个根RelativeLayout,其中包含一个LinearLayout和一个RelativeLayout,LinearLayout可以容纳工具栏、搜索栏和滚动视图。而相对布局应为align ParentBottom=true以保留页脚。确定,正在进行。ScrollView现在显示正确,但RelativeLayout不在屏幕底部,它覆盖在视图顶部,工具栏上方。有没有关于如何修复的想法?