Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法向ScrollView添加页脚-android_Android_Android Layout_Layout_Android Studio_Android Scrollview - Fatal编程技术网

无法向ScrollView添加页脚-android

无法向ScrollView添加页脚-android,android,android-layout,layout,android-studio,android-scrollview,Android,Android Layout,Layout,Android Studio,Android Scrollview,我目前正在开发一个移动应用程序,当我试图将页脚放在滚动视图下时遇到问题 这是我的密码: <RelativeLayout android:id="@+id/RelativeLayout01" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent">

我目前正在开发一个移动应用程序,当我试图将页脚放在滚动视图下时遇到问题

这是我的密码:

<RelativeLayout
    android:id="@+id/RelativeLayout01"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">



    <RelativeLayout

        android:layout_alignParentBottom="true"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/bottomcontent"
        android:orientation="vertical"
        android:background="@drawable/border">
            //the footer is added dynamically
    </RelativeLayout>

<ScrollView
    android:layout_weight="1"
    android:id="@+id/scroller"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true" >
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:id="@+id/contentcontainer">
        <LinearLayout
            android:id="@+id/scrollcontentcontainer"
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            //the content is added dynamically from a layout template
        </LinearLayout>
    </LinearLayout>
</ScrollView>
</RelativeLayout>

//页脚是动态添加的
//内容是从布局模板动态添加的
scrollview的内容是一组相对布局,其中包含一些按钮和文本视图。它是基于我多次充气的布局

页脚只是一个带有一些按钮的线性布局

问题是,我尝试了在互联网上找到的所有不同的解决方案,但都没有奏效。在我的例子中,页脚卡在scrollView的内容下,而不是scrollView本身下,因此我必须向下滚动直到内容结束才能到达页脚。但是页脚应该保留在屏幕底部

我也尝试过这些解决方案,但没有任何效果: - (当我尝试此操作时,屏幕顶部有一个页脚,没有其他内容……) - 还有其他一些(不太好用!)

我还尝试了所有可能的方法,比如使用重力、权重、填充视口、对齐底部。。。但不可能有预期的结果。 最小API设置为14,我使用android studio

谢谢你们的帮助

编辑1: 可抽边线 `在这里输入代码

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:bottom="-2dp"
        android:left="-2dp"
        android:right="-2dp"
        android:top="2dp">
        <shape android:shape="rectangle" >
            <stroke
                android:width="1dp"
                android:color="#000000" />

            <solid android:color="#3b010101" />

            <padding android:left="10dp"
                android:right="10dp"
                android:top="10dp"
                android:bottom="10dp" />
        </shape>
    </item>

</layer-list>

您可以尝试以下方法,我在
相对布局中添加
滚动视图
时也遇到了问题

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <RelativeLayout
        android:id="@+id/bottomcontent"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@drawable/border">
        <!---add something there eg:-->

      <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:text="Test"/>

     </RelativeLayout>


    <ScrollView
        android:id="@+id/scroller"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@id/bottomcontent"
        android:layout_alignParentTop="true">

        <LinearLayout
            android:id="@+id/contentcontainer"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <LinearLayout
                android:id="@+id/scrollcontentcontainer"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

            </LinearLayout>
        </LinearLayout>
    </ScrollView>
</RelativeLayout>

我发现了以下几点。这无疑是造成问题的原因

注意:在平台版本17及更低版本中,RelativeLayout受 一个测量错误,可能导致使用 测量值不正确。(有关详细信息,请参见MeasureSpec.MakeMasureSpec 更多详细信息。)这是在安装RelativeLayout容器时触发的 放置在滚动容器中,如滚动视图或 水平滚动视图。如果自定义视图未正确配备 未指定MeasureSpec模式的度量值已放置在 RelativeLayout,这将作为RelativeLayout默默地工作 将通过一个非常大的测试

已为设置为的应用保留此行为 android:targetSdkVersion=“17”或更早版本在其清单中使用sdk 标签的兼容性。针对SDK版本18或更高版本的应用程序将 接受正确的行为


请检查我的答案,让我知道这是否解决了问题?将
android:layout_over=“@id/bottomcontent”
添加到您的
ScrollView
@JaredRummler Done,仍然不工作(页脚卡在顶部)…遗憾的是,我的页脚仍然在屏幕顶部,没有任何其他内容…@Virthuss这在我的IDE上工作很好,你有什么错误吗?。你能加上可拉伸的边界吗?一点错误都没有。。。请原谅我的英语不好,但你说boarder drawable是什么意思?你能添加这一部分吗?
android:background=“@drawable/border”
你能直接将我的答案xml(全部内容)复制到你的xml中吗。只是检查一下?因为,我无法重新创建此问题