Androidレイアウト - ListView行の内側で、2つのTextViewsを垂直にスタックします

StackOverflow https://stackoverflow.com/questions/4566909

質問

私は始めました FedorのListView実装. 。これが私のlistViewアイテムの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="wrap_content">
<ImageView
      android:id="@+id/image"
      android:layout_width="50dip"
      android:layout_height="50dip" android:src="@drawable/stub" android:scaleType="centerCrop"/>
<TextView
      android:id="@+id/name"
      android:layout_width="0px"
      android:layout_height="0px"
      android:layout_weight="0" android:textSize="20dip" android:layout_marginLeft="10dip"/>
<TextView
      android:id="@+id/address"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_weight="1"  android:textSize="16dip" android:layout_marginLeft="10dip"/>

</LinearLayout>

私のデバイスで私が見ているのは、ImageViewと2つのテキストビューが左から右に順番に表示されます。

私が望むのは、右側のImageView(これはすでに正しい)、ImageViewの右側のTextViewという名前(これは正しい)、およびTextViewという名前の下のアドレスTextViewです。私はこれを適切にレイアウトする方法を理解することができませんでした。

名前に新しい行を追加してその後のアドレステキストを含めることができることを知っていますが、これらの2つの要素を異なるフォントサイズにしたいので、それはオプションではありません。本当にありがとう!

役に立ちましたか?

解決

LinearLayoutの方向を設定し、やりたいことを達成するには、それらのいくつかを使用する必要があります。擬似コードでは、しなければなりません。

<LinearLayout
    android:orientation="horizontal"
    ...>
    <ImageView
        android:id="@+id/image"
        ... />
    <LinearLayout
        android:orientation="vertical"
        ...>
        <TextView
             android:id="@+id/name"
             ...>

        <TextView
             android:id="@+id/address"
             ...>
    </LinearLayout>
</LinearLayout>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top