【问题标题】:How to change max height of item in List view如何在列表视图中更改项目的最大高度
【发布时间】:2012-01-05 19:40:58
【问题描述】:

我有一个愚蠢的问题,但我无法解决它。我有一个带有自定义项目布局的 listView(没什么复杂的 - 三个 TextView),我需要更改以减少列表中项目的高度。我尝试在 item_layout.xml 中设置 android:layout_height="70px" 但似乎这个值对最终高度没有任何影响。

你知道我做错了什么吗?

非常感谢!

在 main.xml 中

<ListView
 android:id="@+id/wf8_card_list"
 android:layout_width="match_parent"
 android:layout_height="160px" 
 android:layout_marginLeft="-10px"
 android:layout_marginRight="-10px"
 android:layout_weight="0.5"
 android:headerDividersEnabled="false"
 android:footerDividersEnabled="false"
 android:cacheColorHint = "#00000000"
 android:listSelector="@drawable/transaction_list_bacground"/>

在 myActivity.java 中

> ListView lv1=(ListView)findViewById(R.id.my%list);
>       lv1.setAdapter(new PaymentAdapter(this,R.layout.list_layout , my_array_list));

在 list_layout.xml 中

<RelativeLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="70px">
 ...
 </RelativeLayout>

【问题讨论】:

    标签: android listview height max


    【解决方案1】:

    这将取决于您的项目。您应该在需要时使项目可扩展。您也可以在适配器的 getView 方法中处理此问题。

    【讨论】:

      猜你喜欢
      • 2014-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-04
      • 1970-01-01
      • 2014-12-23
      • 1970-01-01
      • 2016-10-11
      相关资源
      最近更新 更多