您的位置:首页 > 移动开发 > Android开发

android关于设置list_item高度问题

2014-01-07 11:24 507 查看
当应用中需要使用到列表显示数据的时候,一般都会用到listview这一个控件,listview中的每一项都是一个list_item。

这一个时候,可能需要设置list_item的高度。

一般在根节点上面设置高度如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="145dp"
>

不知道什么原因,没有效果,如果考虑到会使用背景图片,可以考里面再加一层,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="145dp"
android:id="@+id/around_main_list_item_bg"
>


如果不需要使用背景图片,可以在根节点上面,增加minHeight属性

具体可以看这篇文章/article/2813039.html

如果list_item里面的内容非常简单,比如只有一个TextView,可以考虑使用padding属性,由内向外撑大
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: