Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 自定义视图,如listview,在父级和子级之间具有连接线_Android - Fatal编程技术网

Android 自定义视图,如listview,在父级和子级之间具有连接线

Android 自定义视图,如listview,在父级和子级之间具有连接线,android,Android,我正在尝试创建一个带有连接线的自定义listview,如下所示: 父视图 | |----子视图 | |----子视图 | |----子视图 无法绘制到子视图的连接线 您可以通过使用分隔器来实现这一点。分割线可以是包含此线的图像。 另外,如果要查找具有更多子级的listview,可以使用ExpandableListview。将此布局文件用作listview行 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:

我正在尝试创建一个带有连接线的自定义listview,如下所示:

父视图
|
|----子视图
|
|----子视图
|
|----子视图


无法绘制到子视图的连接线

您可以通过使用分隔器来实现这一点。分割线可以是包含此线的图像。
另外,如果要查找具有更多子级的listview,可以使用ExpandableListview。

将此布局文件用作listview行

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:paddingLeft="30dp" >

    <View
        android:id="@+id/VerticalLine"
        android:layout_width="1dp"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:background="@android:color/black" />

    <View
        android:id="@+id/HorizontalLine"
        android:layout_width="50dp"
        android:layout_height="1dp"
        android:layout_centerVertical="true"
        android:background="@android:color/black" />

    <TextView android:text="Your Text Here"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@id/HorizontalLine"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>

then set ListView divider drawable to transparent color and listView divider heightto 0dp.

然后将ListView分隔器可绘制设置为透明颜色,将ListView分隔器高度设置为0dp。

试着为此创建一个自定义布局。我的第一个想法与创建自定义布局相同。你能告诉我如何为它创建一个自定义布局吗?你能为此发布一个图像吗?因为我对虚线有点混淆。这些不是虚线,而是连续的线,因为我可以发布图像(根据策略stackoverflow,从我开始:)。对于这些连续的线条,你能给我一些建议吗?我主要关心的是画出如图所示的线条。这有助于激发新的想法:)