首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Layout_margin不工作

Layout_margin不工作
EN

Stack Overflow用户
提问于 2014-10-02 04:34:35
回答 1查看 2.1K关注 0票数 2

我想在我的layout.But中使用空白区,而不是working.This是我的xml代码:

代码语言:javascript
复制
<?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:我在列表视图中使用它。

EN

回答 1

Stack Overflow用户

发布于 2014-10-02 04:39:43

因为您将widthheight设置为wrap_content,所以需要特别将它们的父LinearLayout更改为match_parent

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26150126

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档