How do I make listview run smoothly when the items have images with various heights? Using recycling and calculating the ImageView dimension in the getView when I go up the list jerks horribly and skips parts Thank you
If you are using Custom Listview With fixed item Height at that time for ImageView you need to use :
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" >
Using this Image which is any size can be Fit to listView Item size
android:adjustViewBounds="true"
android:scaleType="fitXY"
Image Will be Fixed
Don't change the view size on the getView()
method. Instead override the Adapter methods getViewTypeCount()
and getItemViewType()
.
If you use these methods right, returning a different number for different size views, Android will recycle the right view for you on getView()
. This way the list is measured correct and the list will scroll smoothly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.