recyclerView内部的滚动视图导致滞后和内存不足



还有两个视图的内部scrollView,一个包含viewPager,另一个包含recyclerViewViewCompat.setNestedScrollingEnabled(mRvPosts,false);

但仍然滞后和应用程序崩溃。使用分页在滚动时一次加载10个图像。使用了以前的答案,但没有为我提供解决方案。我知道ScrollView/NestedScrollView中的recyclerView是个问题,因为它没有回收recyclerViews项视图。但不知道如何实现它。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/adsView">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical">
<include layout="@layout/content_featured_posts" />

<include layout="@layout/content_recent_posts" />
</LinearLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
<include
android:id="@+id/adsView"
layout="@layout/content_banner_ad" />
<include layout="@layout/view_common_loader" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lyt_recent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_20dp"
android:visibility="gone">
<TextView
android:id="@+id/recent_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_15dp"
android:layout_toStartOf="@+id/view_all_recent"
android:text="@string/recent_posts"
android:textColor="@color/blue"
android:textSize="15sp" />
<TextView
android:id="@+id/view_all_recent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="@dimen/margin_14dp"
android:background="?android:attr/selectableItemBackground"
android:gravity="end"
android:text="@string/view_all"
android:textColor="@color/blue"
android:textSize="15sp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rvRecent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/recent_title"
android:layout_margin="@dimen/margin_10dp"
android:nestedScrollingEnabled="false" />
</RelativeLayout>

java.lang.OutOfMemoryError:OutOfMemoryError在尝试抛出OutOfMemory时抛出;没有可用的堆栈跟踪11-22 13:00:47.468 26842-27769/com.abc I/art:WaitForGcToComplete因Alloc原因被阻止2.117秒11-22 13:00:47.468 26842-27769/com.abc I/art:启动阻塞GC Alloc11-22 13:00:47.468 26842-27769/com.abc I/art:启动阻塞GC Alloc11-22 13:00:47.469 26842-28645/com.abc I/art:等待阻止GC Alloc11-22 13:00:47.470 26842-28589/com.abc I/art:等待阻止GC Alloc11-22 13:00:47.478 26842-28595/com.abc I/art:等待阻止GC Alloc11-22 13:00:47.501 26842-27774/com.abc I/art:等待阻止GC Alloc

尝试将ScrollView更改为NestedScrollViewescendantFocusability线性布局移动到嵌套滚动视图。它在我的情况下工作

最新更新