Android RelativeLayout marginBottom不工作
我正在尝试为RelativeLayout设置marginBottom:Android RelativeLayout marginBottom不工作,android,Android,我正在尝试为RelativeLayout设置marginBottom: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/parentView" android:layout_width="match_parent" android:layout_height="wrap_content" android:backgr
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parentView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:marginBottom="15dp"
android:marginLeft="10dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_marginRight="10dp"
android:layout_marginTop="8dp">
<!-- Rest of thelayout -->
</RelativeLayout>
但是,marginBottom没有效果。为什么?我不知道为什么,但是如果您将marginBottom的高度设置为“包裹”内容,它将不起作用。您可以执行以下操作: 1) 将其高度设置为与父项匹配 2) 使用paddingBottom代替marginBottom 3) 改为使用线性布局
我不知道为什么,但是如果您将marginBottom的高度设置为wrap_内容,它将不起作用。您可以执行以下操作: 1) 将其高度设置为与父项匹配 2) 使用paddingBottom代替marginBottom 3) 改为使用线性布局
更正你的属性如下
android:layout_height="match_parent"
android:layout_marginBottom="15dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="8dp"
更正你的属性如下
android:layout_height="match_parent"
android:layout_marginBottom="15dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="8dp"
如果子视图未填满屏幕,则无法观察底部边距 这就是为什么身高必须是“匹配父项” 如果RelativeLayout的父视图是ScrollView,则RelativeLayout的高度应为“wrap_content”,并将此行添加到xml中的ScrollView
android:fillViewport=“true”
而且
错。试试这个
android:layout_marginBottom="15dp"
android:layout_marginLeft="10dp"
如果子视图未填满屏幕,则无法观察底部边距 这就是为什么身高必须是“匹配父项” 如果RelativeLayout的父视图是ScrollView,则RelativeLayout的高度应为“wrap_content”,并将此行添加到xml中的ScrollView
android:fillViewport=“true”
而且
错。试试这个
android:layout_marginBottom="15dp"
android:layout_marginLeft="10dp"
请对您的问题添加更多描述。@Mohom.R我想问题很清楚。你不明白什么?
layout\u marginBottom
,layout\u marginTop
。如果这是一个输入错误,请更正它,因为它会带来毫无帮助的答案。在页边距的情况下,父视图很重要,所以您应该共享您的RelativeLayout
。请添加您的问题的更多描述。@Mohom.R我想问题很清楚。你不明白什么?layout\u marginBottom
,layout\u marginTop
。如果这是一个输入错误,请更正它,因为它会邀请没有帮助的答案。在页边距的情况下,父视图很重要,因此您应该共享RelativeLayout
的包装。它不是android:marginBottom,而是android:layout\u marginBottom不是android:marginBottom,取而代之的是:布局_marginBottom@overflowed页边距由父布局处理。所有内容都以layout\为前缀。如果父视图不支持页边距,您将无法在子视图上获得页边距。@溢出的页边距由父布局处理。所有内容都以layout\为前缀。如果父视图不支持页边距,则无法在子视图上获取页边距。