gpt4 book ai didi

android - 如何创建这样的按钮组?

转载 作者:行者123 更新时间:2023-11-30 03:46:01 25 4
gpt4 key购买 nike

刚接触android编程,想有这样一个按钮组:

https://www.dropbox.com/s/4x3l797iwgdaha1/2013-02-20%2020.12.57.png

我尝试通过 Dashboard-Layout(来自 Google IO)创建这样的布局,但它看起来不像这样,因为有更高的距离(仪表板中的“边距”。

有没有人建议如何创建“ButtonGroup”布局,就像您在屏幕截图中看到的那样?

提前致谢!

尼克尔伯特

最佳答案

添加android:paddingandroid:gravity当符合 TableLayout 的要求时.


 <TableLayout 
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="2"
android:shrinkColumns="2"
xmlns:android="http://schemas.android.com/apk/res/android">
<TableRow>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ursrouce"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ursrouce"
/>
</TableRow>
<TableRow>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ursrouce"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ursrouce"
/>
</TableRow>
</TableLayout>

您可以根据需要在<ImageButton> 之后添加水平和垂直分隔符

垂直::

<View
android:layout_width="1dip"
android:layout_height="fill_parent"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp"
android:background="#FF0000FF"
/>

水平::

<View
android:layout_width="fill_parent "
android:layout_height="1dip"
android:background="#FF0000FF"
/>

关于android - 如何创建这样的按钮组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14988251/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com