組佈局中的邊距似乎不起作用。LinearLayout,RelativeLayout等邊距不能按預期方式工作
例如,
<?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,但沒有得到回答。
嘗試設置按鈕,中心將它包裝水平 – Nepster 2014-07-17 07:55:38