ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

android-RelativeLayout视图重叠

2019-11-01 16:24:53  阅读:242  来源: 互联网

标签:android-layout android


所需的布局是标题,下面有两个框架(稍后将包含片段),并且按钮固定在屏幕底部:

     Header Text     
----------------------
frame 1   |  frame 2
----------------------
btn 1   btn 2   btn 3

我几乎完成了这种排序(最后是xml),有一个问题…两个框架重叠在按钮上.

我已经对该问题进行了一些搜索,发现this,但是所有的操作都将我的问题从按钮溢出的帧更改为标题溢出的帧.

我还尝试将按钮设置为显示在框架下方,而不是与父级底部对齐,但这只是将其推离屏幕.

当前布局xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <TextView
            android:id="@+id/fdname"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:clickable="true"
            android:gravity="center"
            android:text="No department info has been entered yet"
            android:textSize="25dp" />
    <TextView
            android:id="@+id/fdaddress"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/fdname"
            android:gravity="center"
            android:text="address"
            android:textSize="15dp" />
    <TextView
            android:id="@+id/horizontalline"
            android:layout_width="match_parent"
            android:layout_height="2dip"
            android:layout_below="@id/fdaddress"
            android:background="#ff23cf"
            android:gravity="center_vertical"
            android:paddingBottom="2dip"
            android:paddingTop="2dip" />
    <LinearLayout
            android:id="@+id/frames"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/horizontalline"
            android:orientation="horizontal" >
            <FrameLayout
                    android:id="@+id/leftpane"
                    android:layout_width="0px"
                    android:layout_height="match_parent"
                    android:layout_weight="1" />
            <TextView
                    android:id="@+id/verticalline"
                    android:layout_width="2dp"
                    android:layout_height="match_parent"
                    android:background="#ff23cf"
                    android:gravity="center_horizontal"
                    android:paddingLeft="5dip"
                    android:paddingRight="5dip" />
            <FrameLayout
                    android:id="@+id/rightpane"
                    android:layout_width="0px"
                    android:layout_height="match_parent"
                    android:layout_weight="1" >
            </FrameLayout>
    </LinearLayout>
    <LinearLayout
            android:id="@+id/buttons"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:gravity="center"
            android:orientation="horizontal" >
            <Button
                    android:id="@+id/EventViewButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:minHeight="25dp"
                    android:text="@string/menu_event_view"
                    android:textSize="15dp" 
                    android:layout_weight="1">
            </Button>
            <Button
                    android:id="@+id/MemberViewButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:minHeight="25dp"
                    android:text="@string/menu_member_view"
                    android:textSize="15dp" 
                    android:layout_weight="1">
            </Button>
            <Button
                    android:id="@+id/AttendanceViewButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:minHeight="25dp"
                    android:text="@string/menu_atnd_view"
                    android:textSize="15dp" 
                    android:layout_weight="1">
            </Button>
    </LinearLayout>
</RelativeLayout>

解决方法:

尝试在包含框架的LinearLayout之前声明包含按钮的LinearLayout,并保留android:layout_alignParentBottom =“ true”属性.

然后,向您的框架容器中添加上述约束:

android:layout_below="@id/horizontalline"
android:layout_above="@id/buttons"

这种方式应强制将帧作为最后一帧绘制在屏幕上,从而填充剩余的空间.

希望它能起作用!

标签:android-layout,android
来源: https://codeday.me/bug/20191101/1984975.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有