Android ApiDemos示范解析(163):Views->Layouts->TableLayout->08. Toggle Stretch

Android ApiDemos示例解析(163):Views->Layouts->TableLayout->08. Toggle Stretch

前面例子Android ApiDemos示例解析(159):Views->Layouts->TableLayout->04.Stretchable 介绍了在XML中为列定义Stretchable 属性,本例中代码中动态改变列的Stretchable 属性。

button.setOnClickListener(new Button.OnClickListener() {
 public void onClick(View v) {
 mStretch = !mStretch;
 table.setColumnStretchable(1, mStretch);
 }
});

void setColumnStretchable(int columnIndex, boolean isStretchable)

  • columnIndex: 列的序号,以0开始
  • isStretchable: 指定Stretchable 属性。

Android ApiDemos示范解析(163):Views->Layouts->TableLayout->08. Toggle Stretch