2010-12-30 13 views
4

私はFedor's ListView implementationで始めました。ここに私のリストビュー項目のXMLです:私は私のデバイス上で見ていると、Androidレイアウト - リストビューの行内に2つの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="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つのTextViewsは左から右に順次表示しました。

ImageViewの右端(これはすでに正しい)、ImageViewの右側のTextView(これは正しい)、およびAddress TextView、名前TextViewの下に、ImageViewがあります。私はこれを適切にレイアウトする方法を見つけ出すことができませんでした。

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

答えて

6

LinearLayoutの向きを設定する必要があり、目的を達成するためには、それらのいくつかを使用する必要があります。擬似コードでは、あなたがする必要があります:https://github.com/commonsguy/cw-andtutorials/blob/master/:たとえば

<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> 
+1

、これがために、かなり多くのあなたが求めているものです05-FancyList/LunchList/res/layout/row.xml – CommonsWare

+0

完璧な、これは私が欠けていたものです。ありがとうございました。 –

+0

これで100万ポイントを獲得する必要があります! –

関連する問題