我想在我的layout.But中使用空白区,而不是working.This是我的xml代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/blocks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/mes7"
android:layout_marginRight="6dp"
android:layout_marginTop="6dp"
android:clickable="false">
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="4dp"
android:layout_marginRight="6dp"
android:layout_marginTop="3dp"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="1dp"
android:text="Test Message"
android:textSize="12dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|bottom"
android:text="19:40"
android:textSize="8dp"/>
</LinearLayout>
</LinearLayout>这就是结果:

为什么layout_margin不工作?
Ps:我在列表视图中使用它。
发布于 2014-10-02 04:39:43
因为您将width和height设置为wrap_content,所以需要特别将它们的父LinearLayout更改为match_parent
https://stackoverflow.com/questions/26150126
复制相似问题