当前位置: 代码迷 >> Android >> 怎么设置listview中的行高
  详细解决方案

怎么设置listview中的行高

热度:52   发布时间:2016-05-01 21:45:10.0
如何设置listview中的行高?
简要步骤是先初始化Arrayadapter,类型是string,然后装入listview中。发现每个item尺寸太大,在一个屏幕中放不开。故需要将尺寸(主要是高度)降低。谢谢

------解决方案--------------------
定义每一个item的layout的高度。

比如:

在/layout文件中定义row.xml

Java code
<?xml version="1.0" encoding="UTF-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="horizontal"    android:layout_width="fill_parent"     android:layout_height="10px"        <TextView                android:layout_width="fill_parent"            android:layout_height="fill_parent" /></RelativeLayout>
------解决方案--------------------
行高,是你在adapter中添加布局。在设置布局的高度,还有如果布局是全屏。只要设置布局中的组件layout_height 即可。试试吧
  相关解决方案