Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.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
Android 页脚视图作为输出_Android_Layout - Fatal编程技术网

Android 页脚视图作为输出

Android 页脚视图作为输出,android,layout,Android,Layout,我有一个RelativeLayout,包括以下RelativeLayout: <RelativeLayout android:id="@+id/buttons_bar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:pa

我有一个RelativeLayout,
包括以下RelativeLayout:

<RelativeLayout
        android:id="@+id/buttons_bar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:paddingTop="10dip" >

        <Button
            android:id="@+id/day_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="day"
            android:layout_alignParentLeft="true"
            android:textSize="14sp"/>


        <Button
            android:id="@+id/month_button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="month"
            android:layout_alignParentRight="true"
            android:textSize="14sp"/>

        <EditText
            android:id="@+id/week_button"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/day_button"
            android:layout_toLeftOf="@id/month_button1"
            android:maxLines="5"
            android:minLines="1"
            android:textSize="16sp"
            android:layout_marginBottom="15dp"/>
    </RelativeLayout>

此布局将显示为页面的页脚。 如您所见,EditText的最大行数为5。当EditText中的行大小大于2时,其周围的按钮开始向上移动。 我希望按钮粘在页面的末尾,不要移动。有解决办法吗


我尝试为按钮添加
android:layout\u alignParentBottom=“true”
,但没有成功

这听起来像是UI框架中的一个bug,但通常都有办法实现相同的视觉效果

例如,用
orientation=“horizontal”
替换XML中显示的
RelativeLayout
LinearLayout
,应该会产生相同的视觉效果

伪码

<LinearLayout horizontal>
   <Button wrap_content layout_gravity=bottom/>
   <EditText width=0dp weight=1/> // makes EditText fill remaining space
   <Button wrap_content layout_gravity=bottom/>
</LinearLayout>

//使EditText填充剩余空间
尝试为所有子元素添加android:layout\u alignParentBottom=“true”

它至少在Android Studio中起作用。

已更新

为两个按钮添加
android:layout\u alignBottom=“@+id/week\u button”


我就是这么做的。页脚布局占据了整个页面。请注意,页脚布局在另一个相对布局中。一旦编辑文本行大于1,按钮就会向上移动。ops,我的错误,我在伪代码中添加了两个缺少的参数,这能解决问题吗?