分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
先来上个图,最终效果图。
每个Layout都有自己最适用的场景,而TableLayout往往用在中规中矩的输入界面,比如下图:
TableLayout下嵌套TableRow组成Table的行;每个TableRow中布局不同的控件,组成Table的列。上图就是两列四行,而我们要做的表格就是三行三列。
TableLayout是没有提供边框的,要作成表格的效果需要我们使用一些技巧:
整个TableLayout的背景色设成黑色,而每个Table的cell(其实就是每个控件)的背景色设成白色,然后cell的边距根据情况设置一个px,就可以了。
布局代码如下:
<TableLayout android:id="@+id/table" android:layout_below="@id/spinner" android:layout_width="wrap_content" android:background="@color/black" android:layout_height="wrap_content"> <TableRow android:layout_marginTop="1dp" android:layout_marginRight="1dp" android:layout_marginLeft="1dp" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:text="姓名" android:textSize="@dimen/table_text_size" android:background="@color/white" android:layout_width="@dimen/table_item1_width" android:layout_height="wrap_content" /> <TextView android:text="学校" android:textSize="@dimen/table_text_size" android:background="@color/white" android:layout_marginLeft="1dp" android:layout_width="@dimen/table_item2_width" android:layout_height="wrap_content" /> <TextView android:text="专业" android:textSize="@dimen/table_text_size" android:background="@color/white" android:layout_marginLeft="1dp" android:layout_width="@dimen/table_item3_width" android:layout_height="wrap_content" /> </TableRow> <TableRow android:layout_marginTop="1dp" android:layout_marginBottom="1dp" android:layout_marginRight="1dp" android:layout_marginLeft="1dp" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:text="张飞" android:textSize="@dimen/table_text_size" android:background="@color/white" android:layout_width="@dimen/table_item1_width" android:layout_height="wrap_content" /> <TextView android:text="野鸡大学" android:textSize="@dimen/table_text_size" android:background="@color/white" android:layout_marginLeft="1dp" android:layout_width="@dimen/table_item2_width" android:layout_height="wrap_content" /> <TextView android:text="体育系" android:textSize="@dimen/table_text_size" android:background="@color/white" android:layout_marginLeft="1dp" android:layout_width="@dimen/table_item3_width" android:layout_height="wrap_content" /> </TableRow> <TableRow android:layout_marginBottom="1dp" android:layout_marginRight="1dp" android:layout_marginLeft="1dp" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:text="刘备" android:textSize="@dimen/table_text_size" android:background="@color/white" android:layout_width="@dimen/table_item1_width" android:layout_height="wrap_content" /> <TextView android:text="皇家学院" android:textSize="@dimen/table_text_size" android:background="@color/white" android:layout_marginLeft="1dp" android:layout_width="@dimen/table_item2_width" android:layout_height="wrap_content" /> <TextView android:text="经济" android:textSize="@dimen/table_text_size" android:background="@color/white" android:layout_marginLeft="1dp" android:layout_width="@dimen/table_item3_width" android:layout_height="wrap_content" /> </TableRow> </TableLayout>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80