什么会导致只有部分列表视图项目在点击时突出显示?点击时列表项不会突出显示
我正在开发一个Android应用程序,用户通过一系列列表进行导航,并且某些列表项不能正确突出显示。列表项左侧有图片,后面是文字。如果项目中的文本大部分填充行,则整个行在点击时突出显示。但是,如果文字较短,则只有部分行突出显示。无论文本的长度如何,我都希望整行都能突出显示。我的列表项的布局是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/zoneIcon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:paddingLeft="5dp">
</ImageView>
<TextView
android:id="@+id/itemtitle"
android:layout_width="fill_parent"
android:textColor="@color/listItemColor"
android:textSize="14sp"
android:layout_gravity="top|left"
android:layout_height="fill_parent"
android:padding="13dp"
android:textStyle="bold">
</TextView>
</LinearLayout>
我认为,文中观点layout_width设置为fill_parent
会导致文本视图填补了该项目的宽度的剩余部分,而整行应突出。还有什么我需要设置来控制整个项目的宽度?我究竟做错了什么?
编辑:我还有另一个问题可能有关:当我滚动列表(通常有一个白色背景)时,列表项目在滚动期间变为黑色,然后在滚动时再次显示为正常停止。黑色区域与突出显示的区域大小相同(除了它是所有项目而非仅一个项目),也就是说在滚动时某些项目的右侧存在空白区域。我想阻止列表在滚动时变黑,但也许这是另一个问题。我提到它是因为它让我觉得有些列表项目没有填满他们的父项,但我仍然不确定为什么。
将'android:layout_height =“wrap_content”'属性应用于我的布局中的ListView可修复黑色滚动条,但行上的短选择仍然存在问题。谢谢,尽管......这很好。 – Caleb 2011-04-01 18:38:25