小编Too*_*rop的帖子

使用wrap_content时为什么忽略layout_marginBottom?

我有以下布局文件:

<?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="wrap_content"
    android:background="#FF0000" >

<RelativeLayout
    android:id="@+id/usericon_img"
    android:layout_width="73.3334dp"
    android:layout_height="70.6667dp"
    android:layout_marginBottom="2.6667dp"
    android:layout_marginLeft="3.3334dp"
    android:layout_marginTop="2.6667dp"
    android:background="#FFFFFF" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

在模拟器上(我在真实设备上测试它看起来一样)布局看起来像这样:在此输入图像描述

我的问题是:为什么我在白色布局下没有红色边缘?我知道如果我将外部布局更改为:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="76dp"
android:background="#FF0000" >
Run Code Online (Sandbox Code Playgroud)

我会得到我想要的,但为什么wrap_content不能正常工作?

android margin relativelayout

9
推荐指数
1
解决办法
5686
查看次数

标签 统计

android ×1

margin ×1

relativelayout ×1