您的位置:首页 > 其它

list view item高度设置

2014-07-28 15:17 369 查看
如何设置list view中的item的高度呢?

示例如下:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="@dimen/buy_list_item_height" > //直接在这里设置高度是不会生效的。

  <!—- 具体的item 内容 —>

</RelativeLayout>

按照如下修改:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent" >

<RelativeLayout

android:layout_width="match_parent"

android:layout_height="@dimen/buy_list_item_height" // 再增加一层即可设置高度

android:layout_gravity="center_horizontal" >

    <!—-具体的 item内容 —>

</RelativeLayout>

</RelativeLayout>

另外,如何避免 list view adapter反复getivew?

list view在layout种设置时width/height 为match_parent. 或者为指定的大小。 如果使用wrap_content的话,就很又可能导致反复get view.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: