布局组中的边距似乎无法工作。
例如,
<?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。
我做错了什么吗? 这是一个bug吗?
一种解决方法是使用重力,但这只适用于均匀的边距。
顺便说一下,有一个类似的问题在这里发布,但还没有得到答案。