0

リスト View があります。各行に次のフィールドを表示したい。

 1. An Image 
 2. An TextView For Book Name
 3. An TextView For Author Name
 4. An TextView For File Type 

すべてのことは、私によって成功裏に行われました。しかし、リスト ビューの各行のサイズは、画像で説明されているように、このすべての機能を表示するには十分ではありません。

ここに画像の説明を入力

これを作成するためのコード:

if( row_view == null)
        {
            LayoutInflater inflater = context.getLayoutInflater();
            row_view  = inflater.inflate(R.layout.row_layout, null,true) ;
            holder = new ViewHolder();
            holder.textView_for_BookName = (TextView) row_view.findViewById(R.id.book_text_view_book_tab);
            holder.textView_For_fileType = (TextView) row_view.findViewById(R.id.type_for_book_tab);
            holder.textView_Forauthor = (TextView) row_view.findViewById(R.id.author_text_view_book_tab);
            holder.imageview = (ImageView) row_view.findViewById(R.id.image_sd_list_view);
            row_view.setTag(holder);
        }

rowLayout.xml のコードは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#FFFFFF"
  android:orientation="horizontal">

    <ImageView
    android:src="@drawable/icon"
    android:layout_width="wrap_content"
    android:id="@+id/image_sd_list_view"
    android:layout_height="wrap_content">
    </ImageView>

    <LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="vertical">

        <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="5dip"
        android:paddingBottom="5dip"
        android:textColor="#000000"
        android:textSize="20dip"
        android:paddingLeft="10dip"
        android:text="Book Name"
        android:id="@+id/book_text_view_book_tab">
        </TextView>

        <TextView
        android:id="@+id/author_text_view_book_tab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Author Name"
        android:textColor="#000000"
        android:textSize="13dip"
        android:layout_marginLeft="15dip">
        </TextView>

        <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:text="File Type :"
        android:textColor="#000000"
        android:layout_marginLeft="15dip"
        android:textSize="10dip"
        android:id="@+id/type_for_book_tab">
        </TextView>

    </LinearLayout>

</LinearLayout>

上記のフィールド (book_name,author_name,file_type) を各 textView に表示したいと思います。そのためには、listView の各行のサイズを大きくする必要があります。リスト ビューの行のサイズを大きくするにはどうすればよいですか?? 助けてください....

4

1 に答える 1

0

row_layout.xmlルート レイアウトの高さをwrap_content(またはそれ以上の静的な値)に設定するだけです。

android:height="wrap_content"

(より具体的なヘルプが必要な場合は、投稿する必要がありますrow_layout.xml。)


LinearLayout の両方のheight属性を変更してみてください。

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ...
    />
于 2012-10-07T17:30:50.987 に答える