有没有办法在android的layout中画出来一条线

2026年09月26日 18:01
有3个网友回答
网友(1):

 可以利用TextView来实现,如果要水平线将textView的高设置为1设置背景颜色,竖线将宽设为1。如下代码:

        android:layout_width="fill_parent"  
        android:layout_height="1dp"  
        android:background="#ffffff"  
        />

网友(2):

  可以利用TextView来实现,如果要水平线将textView的高设置为1设置背景颜色,竖线将宽设为1。

网友(3):

找一张图片里面只有一条线(去掉空白部分),长度无所谓,放在res/drawable中,

在layout中添加

	android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/line"/>