android4.0上ListView出现残影

来源:互联网 发布:淘宝劵 编辑:程序博客网 时间:2024/05/01 23:58

先上图:

看到的那些选项实际上就是一张背景了,点不动了。下面是布局代码,这个在4.0之前的版本没有问题,但是4.0上ListView就容易出现残影(上次另一种布局也出现了)。

配置文件是:

        <ListView            android:id="@android:id/list"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:cacheColorHint="@color/transparentColor"            android:background="@color/textColorWhite"            android:divider="@drawable/bg_list_divider"            android:fastScrollEnabled="true"            android:descendantFocusability="afterDescendants"            android:listSelector="@drawable/rc_list_selector_bg"/>        <RelativeLayout            android:id="@+id/no_contact_indication"            android:layout_width="fill_parent"            android:layout_height="fill_parent"            android:background="@color/bgColorMain"            android:fillViewport="true"            android:gravity="center">            <TextView                android:id="@+id/emptyListText"                android:layout_width="fill_parent"                android:layout_height="wrap_content"                android:background="@color/bgColorMain"                android:fillViewport="true"                android:gravity="center"                android:singleLine="true"                android:text="@string/noContacts"                android:textColor="@color/textColorGray"                android:textSize="20sp" />            <ProgressBar                android:id="@+id/loading"                style="@style/RCMProgressBar"                android:visibility="gone"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:layout_centerInParent="true" />        </RelativeLayout>

解决方法就是把TextView的
android:layout_height="fill_parent"

这样改了。就OK了。

或者是把RelativeLayout的

android:layout_height="fill_parent"

改成

            android:layout_height="0dp"            android:layout_weight="1"

(坑爹的是这样改在我的模拟器上第一次进程序搜索没有匹配项时不会显示提示信息。切换一下就又显示了,以为是什么奇怪的问题。结果在两部真机上试了都没问题。。。对应android版本一致)

不知道出现这些问题跟 runQueryOnBackgroundThread 方法有没有关系。搜索时是进入这个方法的。感觉这个方法的机制写的是不是有点问题,怎么总是出现莫名奇妙的界面问题。

原创粉丝点击