我是 android 编程新手,想要有这样一个按钮组:
https://www.dropbox.com/s/4x3l797iwgdaha1/2013-02-20%2020.12.57.png
我尝试通过仪表板布局(来自 Google IO)创建这样的布局,但它看起来不像这样,因为距离(仪表板中的“边距”。
有没有人建议如何像您在屏幕截图中看到的那样创建“ButtonGroup”布局?
提前致谢!
尼克尔伯特
我是 android 编程新手,想要有这样一个按钮组:
https://www.dropbox.com/s/4x3l797iwgdaha1/2013-02-20%2020.12.57.png
我尝试通过仪表板布局(来自 Google IO)创建这样的布局,但它看起来不像这样,因为距离(仪表板中的“边距”。
有没有人建议如何像您在屏幕截图中看到的那样创建“ButtonGroup”布局?
提前致谢!
尼克尔伯特
android:padding将和添加android: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"
     />
如果要制作这种通用格式,可以使用具有两行的 TableLayout,每行有两列,否则,列数设置为 2 的 gridview 也可以为您提供类似的外观。