I have a problem with the list view and its items. When scrolling up/down the listview I noticed that the items slightly resize(about one pixel) and in my application it looks like ^. The divider between two items should be one pixel high(used default android behavior), but when scrolling the divider is sometimes 2 pixels or 0 pixels开发者_如何学Python(not visible). This is bad since it looks like the two items form one list item.
Has anyone a solution for this weird resizing problem when scrolling inside a listview?
My development device is the HTC Wildfire with firmware version 2.1-update1. Emulator is set to:Android 2.1-update1, skin WVGA800 and hw.lcd.density=240.
The ListView is filled with the following item layout and I used default settings for the listview:
<?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="?android:attr/listPreferredItemHeight"
android:background="#F0F0F0">
<ImageView
android:id="@+id/test_icon"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:src="@drawable/icon"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:scaleType="centerInside">
</ImageView>
<TextView
android:id="@+id/testTextView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true"
android:layout_toLeftOf="@+id/test_icon"
android:text="test"
android:textColor="#555555" />
</RelativeLayout>
Thanks!
Try setting android:gravity to center|fill either on the outer element or both internal ones. This fixed a resize-while-scrolling problem I was having.
Try setting the text item to be width="wrap_content"
精彩评论