0
我已经定制了列表视图布局。列表中的项目将会是5或更多。如果不止如此,列表中有5-10个项目,它看起来不错。android listview减少项目填充屏幕
但是,如果有只有5个项目说,空白空间出现在高度较大的设备列表下方。这看起来不太好。
以下是我的列表行布局 -
<?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="wrap_content"
android:background="#FFF"
android:orientation="horizontal"
android:padding="5dip" >
<TextView
android:id="@+id/txt_update_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:paddingLeft="10sp"
android:text="title"
android:textColor="#b73a3e"
android:textStyle="bold"
android:typeface="normal" />
<TextView
android:id="@+id/txt_update_excerpt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txt_update_title"
android:layout_marginTop="1dip"
android:focusable="false"
android:paddingLeft="10sp"
android:paddingRight="10dp"
android:text="text"
android:textColor="#343434"
android:textSize="15dip" />
<TextView
android:id="@+id/txt_uid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dip"
android:layout_toRightOf="@+id/txt_update_title"
android:focusable="false"
android:text="some" />
<ImageView
android:id="@+id/arrow"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignBottom="@+id/txt_uid"
android:layout_alignRight="@+id/txt_update_excerpt"
android:layout_centerInParent="true"
android:scaleType="centerInside"
android:paddingRight="5dp"
android:src="@drawable/arrow" />
</RelativeLayout>
和ListView -
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:id="@+id/tag_line"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/tagline"
android:textColor="#fff" />
<ListView
android:id="@+id/list_updates"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:cacheColorHint="#0000"
android:divider="#00000000"
android:dividerHeight="0px"
android:overScrollMode="never" >
</ListView>
</LinearLayout>
我的愿望是,如果设备的高度是更大的话,我想名单通过缩放高度取完高度每行的方式应显示所有项目不滚动。如果项目多则滚动应该出现。我如何设置?
更新
我可以选择加入一个解决方案,我会找很多项目是如何去那里的名单之前,如果他们是小于5-6,我d选择由LinearLayout组成的不同布局或填充空白区域的其他布局。但我无法弄清楚我需要为这样的LinearLayout
选择结构。我应该选择5-6 LinearLayout在另一个之下还是一个迭代?
你是否意味着它不保留你选择的背景颜色,而是列表的其余部分是主题颜色? – ChiefTwoPencils
取而代之的是背景颜色,我更愿意使用填充整个高度的设备高度来填充那些较少的项目。如果项目多于那么它应该正常显示。 – Gimali
是的,但你的愿望是,因为它看起来不太好。有一个解决方案可以让空白列表区域与其余视图具有相同的背景,因此看起来不错。我认为你的想法存在的问题是各种用法之间的不一致。如果我在一个项目中使用该应用程序,它会不必要地拉伸,如果我有10个,它看起来就像我期望的那样。 – ChiefTwoPencils