在Android中,您可以通過設置layout_width
和layout_height
屬性來調整Button的大小
打開您的項目的res/layout
目錄下的布局XML文件。例如:activity_main.xml
。
在Button標簽中添加android:layout_width
和android:layout_height
屬性,并設置為所需的寬度和高度。您可以使用像素值(例如:48dp
、72dp
)或百分比值(例如:"wrap_content"
、"match_parent"
)。
以下是一些示例:
<Button
android:id="@+id/my_button"
android:layout_width="150dp"
android:layout_height="60dp"
android:text="Click me!" />
<Button
android:id="@+id/my_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Click me!" />
請注意,如果您使用的是相對布局(例如:RelativeLayout
、ConstraintLayout
),則還可以使用其他屬性(如android:layout_alignParentStart
、android:layout_centerInParent
等)來控制Button的位置。