3

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 を含む入れ子になった textview で、水平に配置されたテキスト ビューの間に垂直の区切り線を追加したいと考えています。ハードコーディングされた幅のビューを追加してそうしようとすると、線は親の線形レイアウトから高さ全体に及びます。

    <?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"/>、代わりに使用しようとしましたが、同じ結果が表示されます。

テキストビューを分離するために垂直線を導入して高さを保持する垂直セパレーターをここに配置する方法はありますか? または、別のレイアウトを選択する必要がありますか?

4

2 に答える 2

3

別のオプションは、描画された垂直線の上部と下部とそれぞれの水平方向のエッジの間にスペースを作成するために含めるandroid:layout_margin(または分離layout_marginTopして)ことです。layout_marginBottomLinearLayout.

それ以外に、私RelativeLayout,はあなたの垂直線のビューを調整して、その上下を隣接するものの1つに揃えるようにするかもしれません。TextViews.

于 2013-03-18T15:29:53.040 に答える
1

LinearLayoutまたはVertical Seperatorに固定の高さを与える必要があります

于 2012-10-10T10:32:14.983 に答える