Android 如何动态绘制垂直线?

Android 如何动态绘制垂直线?,android,Android,我希望在表格行内动态绘制垂直线。XML中的某些内容如下所示: 我能够从代码中获得所有布局,除了“视图”。任何建议都将不胜感激 <TableRow> <LinearLayout ...... android:orientation="vertical"> <CheckBox>..</CheckBox> <Button>..</Button> </LinearLayout

我希望在表格行内动态绘制垂直线。XML中的某些内容如下所示:

我能够从代码中获得所有布局,除了“视图”。任何建议都将不胜感激

<TableRow>
   <LinearLayout 
     ......
     android:orientation="vertical">
     <CheckBox>..</CheckBox>
     <Button>..</Button>
  </LinearLayout>

  <View   // this is what I want to achieve, dynamically
    android:layout_width="2dip"
    android:layout_height="fill_parent"
    android:background="#FAFFFB"/>

</TableRow>

..
..
试试这个:

View view = new View(this);
view.setLayoutParams(new LayoutParams(2,LayoutParams.FILL_PARENT));
view.setBackgroundColor(Color.BLACK);
layout.add(view);