Android ApiDemos示范解析(164):Views->Layouts->TableLayout->09. Toggle Shrink
Android ApiDemos示例解析(164):Views->Layouts->TableLayout->09. Toggle Shrink
前面例子Android ApiDemos示例解析(158):Views->Layouts->TableLayout->03.Long Content介绍了在XML中为列定义Stretchable 属性,本例中代码中动态改变列的Stretchable 属性。
button.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { mShrink = !mShrink; table.setColumnShrinkable(0, mShrink); } });
void setColumnShrinkable(int columnIndex, boolean isShrinkable)
- columnIndex: 列的序号,以0开始
- isShrinkable: 指定Shrinkable 属性。