布局视图组——TableLayout

作者:追风剑情 发布于:2015-7-9 21:19 分类:Android

TableLayout以行和列的形式组织视图。使用<TableRow>元素来指定表中的某一行。每一行可以包含一个或多个视图。行内的每个视图构成一个单元格。每一列的宽度由此列中最大单元格的宽度决定。

  1. <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="fill_parent"
  4. android:layout_height="fill_parent"
  5. tools:context="${relativePackage}.${activityClass}" >
  6.  
  7. <TableRow>
  8. <TextView
  9. android:text="User Name:"
  10. android:layout_width="120dp" />
  11. <EditText
  12. android:id="@+id/txtUserName"
  13. android:width="200dp" />
  14. </TableRow>
  15. <TableRow>
  16. <TextView
  17. android:text="Password:"/>
  18. <EditText
  19. android:id="@+id/txtPassword"
  20. android:password="true" />
  21. </TableRow>
  22.  
  23. <TableRow>
  24. <TextView />
  25. <CheckBox android:id="@+id/chkRememberPassword"
  26. android:layout_width="fill_parent"
  27. android:layout_height="wrap_content"
  28. android:text="Remember Password" />
  29. </TableRow>
  30. <TableRow>
  31. <Button
  32. android:id="@+id/buttonSignIn"
  33. android:text="Log In" />
  34. </TableRow>
  35. </TableLayout>

运行效果

tttttttttt.png

标签: Android

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号