增加Android中ListView中的视图大小

时间:2012-10-07 17:20:28

标签: android listview tabview

我有一个列表视图。我想在每一行中显示以下字段。

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

一切都是由我成功完成的。但是,列表视图中每行的大小不足以显示图像中所述的所有此功能。

enter image description here

创建此代码的代码:

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>

我想在每个textView中显示上面的字段(book_name,author_name,file_type)。为此,我必须增加listView中每行的大小。怎么做才能增加列表视图中行的大小?请hlep ....

1 个答案:

答案 0 :(得分:0)

您只需将根布局的高度设置为row_layout.xmlwrap_content(或更大的静态值)。

android:height="wrap_content"

(如果您需要更具体的帮助,则需要发布row_layout.xml。)


尝试更改两个LinearLayout的height属性:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ...
    />
相关问题