如何设置TextView的左侧背景

问题描述:

我有一个文本视图。我想在TextView的左侧添加一个“垂直线”来充当分隔符。如何设置TextView的左侧背景

有没有办法做到这一点?

谢谢。

您可以尝试自定义Drawable背景。它会更容易些,不过,只为您的线路View

<View android:layout_width="2dip" android:layout_height="wrap_content" /> 

,然后将其定位到TextView的左边,无论是通过LinearLayoutRelativeLayout

+0

谢谢。我的TextView已经在一个TableRow中,这将是'scretched column'。所以我不能在我的TextView的左边添加一个视图。如何在背景左侧创建带有图像的可绘制背景? – michael 2010-04-20 05:54:16

+0

“所以我无法在我的TextView的左侧添加视图。”你当然可以。只需将'TextView'和'View'包装在'LinearLayout'中,并将其作为拉伸列的内容。 “我如何用背景左侧的图像创建一个Drawable背景?”您可以为此设置一个九个补丁的PNG:http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch – CommonsWare 2010-04-20 10:47:56