标签:android style class blog c code
android:layout_column="1" 控制Table View在第几列:
<TextView android:layout_column="1" android:text="@string/table_layout_6_open" android:padding="3dip" />
android:stretchColumns="1 控制第几列被拉长
代码设置
table.setColumnStretchable(int column, boolean );
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:stretchColumns="1">
或者代码中设置 table.setColumnCollapsed(0, boolean);
获取是否隐藏
boolean= table.isColumnCollapsed( int column);
<span style="font-size:12px;"><TableLayout android:id="@+id/menu" android:layout_width="match_parent" android:layout_height="wrap_content" android:stretchColumns="1" android:collapseColumns="2"></span>
void android.widget.TableLayout.setColumnShrinkable(int columnIndex, boolean isShrinkable)
public void setColumnShrinkable (int columnIndex, boolean isShrinkable)
Added in API level 1
Makes the given column shrinkable or not. When a row is too wide, the table can reclaim extra space from shrinkable columns
Calling this method requests a layout operation.
Related XML Attributes
android:shrinkColumns
Parameters
columnIndex the index of the column
isShrinkable true if the column must be shrinkable, false otherwise. Default is false.
设置tableitem占两列
android:layout_span="2"
代码设置
View tabChildView = new View(this); //比如这个view是你放在TableLayout中的
LayoutParams lp = tabChildView.getLayoutParams(); //先得到这个view原先的布局参数
//构造一个TableRow.LayoutParams,它是子类,把lp传进去这样之前的布局参数就在该子类中了
TableRow.LayoutParams tlp = new TableRow.LayoutParams搜索(lp);
tlp.span = 3;//TableRow.LayoutParams可以设置这个属性
tabChildView.setLayoutParams(tlp); //别忘了把参数设置回去
2D01-View-Layout-Table-Layout,布布扣,bubuko.com
标签:android style class blog c code
原文地址:http://blog.csdn.net/zhi07/article/details/26454337