Android按钮间距怎么设置

373
2023/7/27 21:02:47
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

您可以使用android:layout_margin属性来设置Android按钮之间的间距。

例如,以下是一个按钮布局,其中包含两个按钮,它们之间有10dp的间距:

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮1"
android:layout_marginEnd="10dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮2"/>
</LinearLayout>

在这个例子中,通过在第一个按钮上设置android:layout_marginEnd="10dp",在按钮之间创建了10dp的间距。您可以根据需要调整间距的大小。

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: Android setOutlineProvider与动画效果的结合