我想用我的保证金它layout.But不是working.This是我的XML代码:Layout_margin不工作
<?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:我正在使用它与一个列表视图。
让你顶的LinearLayout有'的android:layout_width = “match_parent”' – dharms 2014-10-01 20:40:15
我尝试过,但没有奏效。 – 2014-10-01 20:45:20
实际上你不需要顶部的LinearLayout。删除它并将布局宽度添加到剩余的LinearLayout。 – dharms 2014-10-01 20:46:45