【发布时间】:2011-07-21 17:38:48
【问题描述】:
组布局中的边距似乎不起作用。
例如,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_margin="40dip"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="I'm a button" />
</LinearLayout>
应该在所有边显示一个具有 40p 边距的按钮。但是,它的右侧和底部有 80p 的边距。
我做错了吗? 这是一个错误吗?
一种解决方法是使用重力,但这仅适用于均匀边距。
顺便说一句,有一个类似的问题posted here,但没有得到回答。
【问题讨论】:
-
尝试将按钮中心设置为水平
标签: android margin android-linearlayout