android4.0上ListView出現殘影
阿新 • • 發佈:2019-02-02
先上圖:
看到的那些選項實際上就是一張背景了,點不動了。下面是佈局程式碼,這個在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 方法有沒有關係。搜尋時是進入這個方法的。感覺這個方法的機制寫的是不是有點問題,怎麼總是出現莫名奇妙的介面問題。