<?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
中設置填充時,它也不起作用。這裏有什麼問題?你能給我任何解決辦法嗎?如果設置爲android:layout_height="wrap_content"
<RelativeLayout>
,而不是將其設置爲match_parent和檢查爲什麼marginBottom不能正常工作?
'fill_parent'從API級別8開始被棄用,並由'match_parent'取代。 – 2013-06-09 03:31:05
@RosePerrone是的我知道,但我認爲這個答案已發佈2年;) – 2013-06-09 05:29:45
只需更新您的答案 – 2013-06-09 16:07:57