Android:在垂直线性布局中嵌套的水平线性布局中的文本视图之间放置垂直分隔线/分隔线?

Android:在垂直线性布局中嵌套的水平线性布局中的文本视图之间放置垂直分隔线/分隔线?,android,android-layout,android-linearlayout,android-view,textview,Android,Android Layout,Android Linearlayout,Android View,Textview,对于android内容视图,我有一个垂直的线性布局,其中包含一些文本视图,这些文本视图有一些线来分割和分隔垂直元素,这很好,下面是xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layou

对于android内容视图,我有一个垂直的线性布局,其中包含一些文本视图,这些文本视图有一些线来分割和分隔垂直元素,这很好,下面是xml

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="@string/A" />                 
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="@string/B" />
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="@string/C" />    
    </LinearLayout>    
    <View 
         android:background="#ffffff" 
         android:layout_width = "fill_parent"
         android:layout_height="1dip"/>    
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/D" />
    <View  
         android:background="#ffffff" 
         android:layout_width = "fill_parent"
         android:layout_height="1dip" />
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/E" />
    </LinearLayout>

现在,我想在带有字符串a/B/C的嵌套文本视图中水平放置的文本视图之间添加一条垂直分隔线。当我尝试通过添加硬编码的宽度视图来执行此操作时,该线跨越父线性布局的整个高度

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="@string/A" />         
        <!--the vertical line separator-->
        <View  
     android:background="#ffffff" 
     android:layout_width = "1dip"
     android:layout_height="fill_parent" />         
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="@string/B" />
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="@string/C" />    
    </LinearLayout>    
    <View 
         android:background="#ffffff" 
         android:layout_width = "fill_parent"
         android:layout_height="1dip"/>    
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/D" />
    <View  
         android:background="#ffffff" 
         android:layout_width = "fill_parent"
         android:layout_height="1dip" />
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/E" />
    </LinearLayout>

对于这个垂直分隔符视图,我尝试使用android:layout\u height=“wrap\u content”/>,但给出了相同的结果


这里有没有一种方法可以使用垂直分隔符,通过引入垂直线分隔文本视图来保持高度?或者我必须选择不同的布局?

你必须给你的线性布局或垂直分隔符指定一个固定的高度

另一个选项可能是包括
android:layout\u margin
(或分开
layout\u marginTop
layout\u marginBottom
)在绘制的垂直线的顶部和底部与
线性布局的相应水平边缘之间创建空间。


除此之外,我可能会尝试一个
相对视图,
并调整垂直线视图,使其顶部和底部与相邻的
文本视图之一对齐。

是的,这在某种程度上是一个解决方案,但它不适合更改文本大小。我希望有一个更优雅的解决方案。我放了20滴,是的,这很有效。但是我担心硬编码的高度可能会导致以后的问题。为什么不使用“匹配父项”作为高度属性呢?