1

カスタム リストの行にレイアウトを使用しています。このレイアウトでは、画像が左側にあり、右側に 2 つのテキスト ボックスが重なっています。一番上のテキストボックスを2つに分割したいと思います。このような:

-------------------------------
|    |  Topleft  |  Topright  |
|ICON|-------------------------
|    |  bottom                |
-------------------------------

私はすでにこれを持っています:

<?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="?android:attr/listPreferredItemHeight"
    android:padding="6dip">
    <ImageView
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginRight="6dip"
        android:src="@drawable/ic_launcher" />
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="fill_parent">

        <LinearLayout 
            android:orientation="vertical" 
            android:layout_width="fill_parent" 
            android:layout_height="0dip"
            android:layout_weight="1">

        <TextView
            android:id="@+id/toptext"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:gravity="center_vertical"
        />
        <TextView
            android:id="@+id/toptext2"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:gravity="center_vertical"
        />
        </LinearLayout>
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1" 
            android:id="@+id/bottomtext"
            android:singleLine="true"
            android:ellipsize="marquee"
        />
    </LinearLayout>
</LinearLayout>

しかし、これは機能していません。トップテキストは 1 つだけで機能しますが、2 つでは機能しません。誰かが私が間違っていることを教えてもらえますか?

4

1 に答える 1

1

orientationLinearLayout の をtopTexttopText2に変更するだけ"horizontal"です。がデフォルトの向きであるため"horizontal"、属性全体を削除できます。

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="0dip"
    android:layout_weight="1">

ただし、TextView で長い文字列を使用していない場合は、3 つの LinearLayout の代わりに 1 つの RelativeLayout を使用できる場合があります。

于 2012-11-07T22:36:36.047 に答える