2011-03-20 113 views
2

我想在表格行内动态绘制垂直线。有些东西就像下面的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> 

回答

3

试试这个:

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