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

标签 android xml layout

刚接触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/

相关文章:

android - Sqlite 数据库 onCreate 参数

Android 套接字每 20 秒卡住一次

c++ - 将参数传递给命令模式

php - 通过 SimpleXML PHP 编辑 XML 节点

android - 用于创建 android UI 主题的工具

android - 向 TextView 添加多个字符串

Android xml sp, dp, px 问题

android - 检查位图中的单个像素,如何存储位图?

c# - 我如何使用 XmlTextReader 读取保管箱上的 xml 文件

html - 固定的 Div 位置在 Firefox 上表现不同