为什么marginBottom不工作? [英] why marginBottom not working?

查看:174
本文介绍了为什么marginBottom不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/messageLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/messageSender"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="5dp"/>

    <TextView
        android:id="@+id/messageSenderName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/messageSender"
        android:ellipsize="end"
        android:maxLines="1"
        android:singleLine="false"
        android:textColor="@color/list_text_color"
        android:textSize="16dp"
        android:layout_marginTop="5dp" />

    <TextView
        android:id="@+id/messageContent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/messageSender"
        android:layout_below="@id/messageSenderName"
        android:ellipsize="end"
        android:maxLines="1"
        android:singleLine="false"
        android:textColor="@color/codeFont"
        android:textSize="13dp"/>
</RelativeLayout>

在我的布局,我有问题。当我设置 marginTop =5DP这很好,但是当我使用 marginBottom 什么也没有发生在我的布局。此外,当我设置填充的 RelativeLayout的这也不行。有什么问题吗?你能给我任何解决办法吗?

In my layout I have problem. When I set marginTop="5dp" it's fine, but when I use marginBottom nothing happens in my layout. Also when I set padding in RelativeLayout it does not work either. What is the problem here? Could you give me any solution?

推荐答案

marginBottom有,如果你设置的android没有影响:对&LT layout_height =WRAP_CONTENT; RelativeLayout的&GT; ,而是将它设置为 match_parent 并检查。

marginBottom has no effect if you set android:layout_height="wrap_content" for <RelativeLayout>, instead set it as match_parent and check.

这篇关于为什么marginBottom不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆