对于android内容视图,我有一些垂直线性布局,其中包含一些textviews,用于划分和分隔垂直元素,此工作正常,xml位于下方。Android:在垂直线性布局中嵌入水平线性布局的文本视图之间放置垂直分隔线/分隔线?
<?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_height="wrap_content"/>
代替,但同样的结果被呈现。
有没有办法在这里有一个垂直分隔符,其中的高度保存,并引入一个垂直线来分隔textviews?或者我必须选择不同的布局?
为什么不使用“match_parent”作为高度属性? – Guardanis