tablelayout,TableLayout布局中,通常将用户添加的组件放在

http://www.itjxue.com  2023-01-20 20:35  来源:未知  点击次数: 

android的:tableLayout和gridview有什么不同

tableLayout是表格布局,用的比较少,实现如下图所示效果

注:TableLayout用的比较少,目前android support v7里面有一个gridlayout,它比TabLayout更容易使用,使用更强大,可以试试

GridView 实现网格布局,比如android手机桌面应用程序的排列,就可以用GridView来实现,具体效果如下:

tablelayout如何将表格置底

tablelayout将表格置底的方法:

可以做一个一行两列的表格,整体设置高度100%,然后把下面的单元格高度固定,把分页的内容放进去,就可以了。

tableLayout 属性用来显示表格单元格、行、列的算法规则。固定表格布局:固定表格布局与自动表格布局相比,允许浏览器更快地对表格进行布局。

android ui开发中,tablelayout的列数是怎么计算的

TableLayout,表格布局采用行列形式管理UI组件,TableLayout不需要明确地声明有多少行和列,而是通过添加TableRow、其它组件来控制表格的行数、列数。

每次向TableLayout添加一个TableRow,就是在向表格添加一行,TableRow也是容器,可以向TableRow中添加组件,每添加一个组件,即是添加一列。

如果直接向TableLayout添加组件,则认为这个组件占用一行。

表格布局中列的宽度即是每一列中最宽的组件的宽度。

使用前:

\

使用后:

\

TableLayout

android:id="@+id/tableLayout1"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:stretchColumns="*"

TableRow

android:id="@+id/tableRow1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

Button

android:text="最近联系人"

android:id="@+id/button4"

android:layout_width="1dip"

android:layout_height="wrap_content"/Button

Button

android:text="联系人"

android:id="@+id/button5"

android:layout_width="1dip"

android:layout_height="wrap_content"/Button

Button

android:text="分组"

android:id="@+id/button5"

android:layout_width="1dip"

android:layout_height="wrap_content"/Button

/TableRow

/TableLayout

TableLayout

android:id="@+id/tableLayout1"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:stretchColumns="*"

TableRow

android:id="@+id/tableRow1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

Button

android:text="最近联系人"

android:id="@+id/button4"

android:layout_width="1dip"

android:layout_height="wrap_content"/Button

Button

android:text="联系人"

android:id="@+id/button5"

android:layout_width="1dip"

android:layout_height="wrap_content"/Button

Button

android:text="分组"

android:id="@+id/button5"

android:layout_width="1dip"

android:layout_height="wrap_content"/Button

/TableRow

/TableLayout

TableLayout 增加一个属性 android:stretchColumns="*" 表示所有列都要自动拉伸,以便适应屏幕宽度。

它的值即可以是数字,也可以是*,注意数字是从0开始的,即:android:stretchColumns="1" 是设置 TableLayout所有行的第二列为扩展列。

上面我们会看到 第1列的按钮比其他列的按钮要宽,如果我们想都一样宽如何办呢?

一个简单办法:

android:layout_width="1dip"

(责任编辑:IT教学网)

更多

推荐测评专题文章