[英]Android relative layout bottom margin not working correctly
我是第一次创建动态布局应用程序。 我正在从在线数据库中获取数据,并使用XML布局将其呈现给用户。
我的下边距有问题。 它被另一个相对布局掩盖了,它位于主要相对布局内,而我已经尽一切努力使它显示并且没有结果。
因此,在使用设置近两个小时之后,我决定请大家指出我做错了什么。
这是它在屏幕上的外观
您会注意到底部的灰色边框部分丢失了。 我在相对布局中使用相对布局。 因此,主布局为灰色并用作边框的背景,而第二个相对布局实际上包含所有其他视图。
这是我的XML文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:background="#ffffff"
android:id="@+id/item_container">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:background="#e8e8e8"
android:id="@+id/item_body"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="false"
android:layout_alignParentRight="false"
android:layout_alignWithParentIfMissing="false"
android:layout_alignParentBottom="false"
android:layout_marginBottom="5dp"
android:layout_margin="5dp">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background"
android:id="@+id/item_button"
android:layout_margin="2dp"
android:clickable="true"
android:longClickable="true"
android:focusable="true"
android:focusableInTouchMode="false"
android:minHeight="55dp">
<FrameLayout
android:layout_width="3dp"
android:layout_height="fill_parent"
android:background="@android:color/transparent"
android:id="@+id/item_indicator"></FrameLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="141-SAMOBOR-RAKOV POTOK-JAGNJIĆ DOL"
android:id="@+id/item_text"
android:layout_gravity="center_vertical"
android:layout_marginLeft="8dp"
android:layout_marginRight="30dp"
android:textAppearance="@android:style/TextAppearance.Small"
android:gravity="fill" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/item_icon"
android:layout_gravity="center_vertical|right"
android:background="@android:color/transparent"
android:src="@drawable/plus_t"
android:layout_marginRight="5dp"
android:contentDescription="Proširi" />
</FrameLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/item_image_container"
android:layout_below="@+id/item_body"
android:layout_marginTop="5dp"
android:background="#ffffff">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/item_image"
android:background="@android:color/transparent"
android:layout_centerHorizontal="true"
android:scaleType="fitCenter" />
</RelativeLayout>
</RelativeLayout>
我已经添加了该结构的图像,因此更容易理解我在这里所做的事情。
我为这个问题感到抱歉,这是我的第三个Android应用程序,我仍在学习中,我正在尝试学习如何使用此应用程序创建动态视图/布局。 我感谢你们花时间阅读和帮助我。
提前致谢。
这是您的2nd RelativeLayout和1st FrameLayout的外观。 您没有使用padding
属性。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:padding="2dp"
android:background="#e8e8e8"
android:id="@+id/item_body">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"
android:id="@+id/item_button"
android:clickable="true"
android:longClickable="true"
android:focusable="true"
android:focusableInTouchMode="false"
android:minHeight="55dp">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.