我有一个具有以下布局的ListView
:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:inevent="http://schemas.android.com/apk/lib/com.estudiotrilha.inevent.view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingBottom="8dp"
android:id="@+id/list_events"
android:addStatesFromChildren="true" >
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="180dp"
android:padding="1dp"
android:background="@drawable/post" >
<ImageView
android:id="@+id/imageEventCover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/event_cover"
android:scaleType="centerCrop" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:visibility="gone"
android:layout_marginTop="25dp" />
<com.estudiotrilha.inevent.view.NewTextView
android:id="@+id/textIsEnrolled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="ENROLLED"
android:textColor="@color/infoText"
inevent:textFor="small"
android:background="@color/infoBoxRed"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_margin="10dp" />
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/event_mark"
android:layout_marginBottom="12dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="10dp"
android:paddingBottom="10dp" >
<com.estudiotrilha.inevent.view.NewTextView
android:id="@+id/textEventName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lisbon Challenge"
inevent:textFor="h3"
android:paddingBottom="10dip"/>
<ImageView
android:id="@+id/imageCalendar"
android:layout_below="@+id/textEventName"
android:layout_width="18dp"
android:layout_height="18dp"
android:contentDescription="@string/facebookHolder"
android:src="@drawable/ic_action_go_to_today" />
<com.estudiotrilha.inevent.view.NewTextView
android:id="@+id/textEventDuration"
android:layout_below="@+id/textEventName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/imageCalendar"
android:layout_marginLeft="5dp"
android:textColor="#555"
inevent:textFor="small"
android:text="MAI 05-11, 2014" />
<ImageView
android:layout_below="@+id/textEventName"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_toLeftOf="@+id/textEventPlace"
android:contentDescription="@string/facebookHolder"
android:src="@drawable/ic_action_place" />
<com.estudiotrilha.inevent.view.NewTextView
android:layout_below="@+id/textEventName"
android:id="@+id/textEventPlace"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="5dp"
android:textColor="#555"
inevent:textFor="small"
android:text="Lisbon, Portugal" />
</RelativeLayout>
</RelativeLayout>
<View android:layout_width="fill_parent"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp"
android:layout_height="3dp"
android:background="@drawable/shadow"/>
</LinearLayout>
在该ListView
中,将放置几个带有图像的项目。
以下是真实交易的一个例子:
问题是所有映像都是异步加载的。
我正在使用通用图像装载机加载这些图像。
我应该做些什么来优化列表呢?
谢谢。
发布于 2014-05-27 15:07:13
快速滚动被称为“抛出”,在动态加载图像的列表上(从web或本地商店)自然会非常密集,因此在移动平台上处理它的唯一方法是:
( a)通过添加临时“加载映像”来改善用户体验:
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.ic_stub) // resource or drawable
.build();
( b)在发生放纵事件时,不要尝试任何过程密集的渲染。屏幕移动得太快,无法呈现任何有用的内容,所以您最好等到屏幕不移动后再尝试呈现任何内容:
boolean pauseOnScroll = false; // or true
boolean pauseOnFling = true; // or false
PauseOnScrollListener listener = new PauseOnScrollListener(imageLoader, pauseOnScroll, pauseOnFling);
listView.setOnScrollListener(listener);
https://stackoverflow.com/questions/23892401
复制相似问题