今天想写个九宫格的布局,baidu了一下,网上的代码大同小异,但是都不能实现竖直方向上的居中,于是就自己研究了一下,分享于此.先看看效果图:
分别是横屏和竖屏的,其他扩张大家可以自行添加了.
布局代码如下:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*" >
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="#B7B7B7" />
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"