【问题标题】:Increasing The Size Of View In ListView in Android在Android中增加ListView中视图的大小
【发布时间】:2012-09-28 01:45:12
【问题描述】:

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

 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>

我想在每个 textView 中显示上述字段 (book_name,author_name,file_type)。为此,我必须增加 listView 中每一行的大小。如何增加列表视图中行的大小?请帮忙....

【问题讨论】:

  • 尝试将图像的大小更改为符合您要求的某个值。
  • 我不喜欢这个主意。你能提出另一个想法吗?

标签: android listview tabview


【解决方案1】:

您只需将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"
    ...
    />

【讨论】:

  • 我无法理解你的说法。你能告诉我更多吗? “row_layout.xml”的代码只是为了大家方便讨论而添加的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-26
  • 2015-07-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多