我想定制不同项目之间的列表视图项目空间。我们通常会显示带有默认空间的列表项,以便在列表中查看。我想要自定义它们之间的空间差异,以便可以一次将更多的数据显示在显示部分的列表中。如何自定义它们之间的列表视图项目空间?
请给我提供一些解决方案。
谢谢进阶 Praween
我想定制不同项目之间的列表视图项目空间。我们通常会显示带有默认空间的列表项,以便在列表中查看。我想要自定义它们之间的空间差异,以便可以一次将更多的数据显示在显示部分的列表中。如何自定义它们之间的列表视图项目空间?
请给我提供一些解决方案。
谢谢进阶 Praween
以编程方式改变填充?
定义ListView时,您有两个布局组件。 您有:
这种布局的布局可以让你定义显示什么时候该列表是空的或填充。请注意0和android:id="@+id/android:empty"
下面的内容,以便您决定要显示的内容。这里的一个示例:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp">
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:layout_weight="1"
android:drawSelectorOnTop="false"/>
<TextView android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF0000"
android:text="No data"/>
</LinearLayout>
这种布局将定义每个条目将如何显示的布局。根据我的说法,这是你所感兴趣的。例如,如果你想要一个条目中的两个信息的条目的布局将类似于这样:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/text1"
android:textSize="16sp"
android:textColor="#99FFFFFF"
android:layout_width="fill_parent"
android:layout_height="20px"/>
<TextView android:id="@+id/text2"
android:textSize="13sp"
android:textColor="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="20px"/>
</LinearLayout>
所以,现在你只需要修改的最后一个例子布局和管理它,你想要的方式。 希望我能帮上忙,如果您需要更多信息请不要犹豫。
@Jim:您应该将该问题添加为评论,而不是回答 – Macarse 2010-04-10 22:02:02
这是一个答案。 – 2010-04-10 22:21:06
这不是一个答案。这是一个问题。看到那个小“?”事情到底? – gnovice 2010-04-11 01:47:50