我想要在表格行内动态绘制一条垂直线。 XML 中的一些内容如下所示:
我能够从代码中获取除“ View ”之外的所有布局。任何建议将不胜感激!
<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);
关于android - 如何动态绘制垂直线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5371214/