tableLayout 的 android:collapseColumns 和 android:shrinkColumns 的区别 [英] difference between android:collapseColumns and android:shrinkColumns of tableLayout

查看:40
本文介绍了tableLayout 的 android:collapseColumns 和 android:shrinkColumns 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 android 开发的新手.我正在阅读TableLayout,其中有三个主要属性

I am new in android development. I was reading TableLayout, Which have three major attributes

android:stretchColumns,android:collapseColumns &机器人:收缩列.

android:stretchColumns, android:collapseColumns & android:shrinkColumns.

经过一些研究,我明白了 android:strechColumns 的确切含义,但我对 collapseColumns 和 shrinkColumns 感到困惑.官方文档说.

After Some Research I got what exaclty meant by android:strechColumns but i am confused between collapseColumns and shrinkColumns. The official docs Saying.

android:shrinkColumns

android:shrinkColumns

要收缩的列的从零开始的索引.列索引必须用逗号分隔:1、2、5.非法和重复的索引将被忽略.您可以使用值*"来缩小所有列.请注意,一列可以同时标记为可拉伸和可收缩.

The zero-based index of the columns to shrink. The column indices must be separated by a comma: 1, 2, 5. Illegal and duplicate indices are ignored. You can shrink all columns by using the value "*" instead. Note that a column can be marked stretchable and shrinkable at the same time.

android:collapseColumns

android:collapseColumns

要折叠的列的从零开始的索引.列索引必须用逗号分隔:1、2、5.非法和重复的索引将被忽略.

The zero-based index of the columns to collapse. The column indices must be separated by a comma: 1, 2, 5. Illegal and duplicate indices are ignored.

shrinkcollapse 究竟是什么意思.谁能告诉我它们之间有什么区别?

What is exactly mean by shrink and collapse .Could anyone tell me what is difference between them?

推荐答案

  • android:stretchColumns

    • android:stretchColumns

      要拉伸的列的从零开始的索引.列索引必须用逗号分隔:1、2、5.非法和重复的索引将被忽略.您可以使用值*"来拉伸所有列.请注意,一列可以同时标记为可拉伸和可收缩.

      The zero-based index of the columns to stretch. The column indices must be separated by a comma: 1, 2, 5. Illegal and duplicate indices are ignored. You can stretch all columns by using the value "*" instead. Note that a column can be marked stretchable and shrinkable at the same time.

      android:shrinkColumns

      android:shrinkColumns

      要收缩的列的从零开始的索引.列索引必须用逗号分隔:1、2、5.非法和重复的索引将被忽略.您可以使用值*"来缩小所有列.请注意,一列可以同时标记为可拉伸和可收缩.

      The zero-based index of the columns to shrink. The column indices must be separated by a comma: 1, 2, 5. Illegal and duplicate indices are ignored. You can shrink all columns by using the value "*" instead. Note that a column can be marked stretchable and shrinkable at the same time.

      android:collapseColumns

      android:collapseColumns

      要折叠的列的从零开始的索引.列索引必须用逗号分隔:1、2、5.非法和重复的索引将被忽略.

      The zero-based index of the columns to collapse. The column indices must be separated by a comma: 1, 2, 5. Illegal and duplicate indices are ignored.

      <TableLayout  
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:stretchColumns="*"
      android:background="@color/grey">
      <TableRow>
          <TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_column="0"
              android:background="@color/red"
              android:textColor="@android:color/white"
              android:textSize="30dp"
              android:text="0" />
      
          <TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_column="1"
              android:textColor="@android:color/white"
              android:textSize="30dp"
              android:background="@color/green"
              android:text="1" />
      
          <TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_column="2"
              android:textColor="@android:color/white"
              android:textSize="30dp"
              android:background="@color/blue"
              android:text="2" />
      </TableRow>
      
      
      <TableRow>
          <TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_column="0"
              android:background="@color/red"
              android:textColor="@android:color/white"
              android:textSize="30dp"
              android:text="0" />
      
          <TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_column="1"
              android:textColor="@android:color/white"
              android:textSize="30dp"
              android:background="@color/green"
              android:text="1" />
      
          <TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_column="2"
              android:textColor="@android:color/white"
              android:textSize="30dp"
              android:background="@color/blue"
              android:text="2" />
        </TableRow>   
       </TableLayout>
      

    • 说明:

      android:stretchColumns="*"

      意味着它根据表格布局宽度平均拉伸所有列

      Means it stretch all columns equally according table layout width

      android:shrinkColumns="*"

      意味着它缩小了所有列

      android:shrinkColumns="0,2"

      android:stretchColumns="1"

      表示第 0 列和第 2 列是换行包含,第 1 列拉伸到可用宽度

      Means column 0 and 2 are wrap contain and column 1 stretch into available width

      android:stretchColumns="0,1,2"

      android:shrinkColumns="1"

      表示如果列已经拉伸然后收缩不适用

      Means if column already stretch then shrink not apply

      android:shrinkColumns="*"

      android:collapseColumns="1"

      android:collapseColumns 意味着它隐藏给定的列

      android:collapseColumns means it hide given column

      android:stretchColumns="*"

      TextView :- android:layout_column="2"

      表示如果 tablerow 第一列布局参数不是以 0 开头,则将空视图添加到行中

      Meanning if tablerow first column layout parameter not start with 0 then empty view added into row

      android:stretchColumns="*"

      android:collapseColumns="1"

      TextView :- android:layout_column="2"

      表示如果 tablerow 第一列布局参数不以 0 开头,则将空视图添加到行中,但如果折叠列然后添加空视图,则不会隐藏该列索引,仅通过显式视图隐藏添加的视图

      Means if tablerow first column layout parameter not start with 0 then empty view added into row but if you collapse column then added empty view not hide of that column index only hide added view by explicit view

      这篇关于tableLayout 的 android:collapseColumns 和 android:shrinkColumns 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆