在Android中,您可以使用layout_margin
屬性來(lái)調(diào)整Button的邊距
打開(kāi)XML布局文件,找到Button控件。
使用android:layout_margin
屬性為Button設(shè)置邊距。例如:
<Button
android:id="@+id/my_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="點(diǎn)擊我"
android:layout_margin="10dp" />
在這個(gè)例子中,android:layout_margin="10dp"
為Button設(shè)置了10dp的上、下、左、右邊距。
android:layout_marginTop
:設(shè)置上邊距android:layout_marginBottom
:設(shè)置下邊距android:layout_marginLeft
:設(shè)置左邊距android:layout_marginRight
:設(shè)置右邊距例如:
<Button
android:id="@+id/my_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="點(diǎn)擊我"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" />
在這個(gè)例子中,我們分別設(shè)置了Button的上邊距為10dp,下邊距為10dp,左邊距為20dp,右邊距為20dp。