小编Bit*_*ech的帖子

RecyclerView 列表较大时严​​重滞后

当适配器中有超过 50 个项目时,我在 recyclerview 上面临严重的滚动滞后。片段跳帧,UI/UX 受到严重影响。我以延迟加载的方式从网络动态填充列表。

查看问题

我的 recyclerview 配置如下:

    myRecyclerView=getActivity().findViewById(R.id.myRecyclerView);
    myListAdapter.setHasStableIds(true);
    myListAdapter=new myListAdapter(myRecyclerView,getContext(),R.id.webMRFrame);
    myRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    myRecyclerView.setHasFixedSize(false);

    myRecyclerView.setItemViewCacheSize(200);
    myRecyclerView.setDrawingCacheEnabled(true);
    myRecyclerView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
    myRecyclerView.setNestedScrollingEnabled(false);
    myRecyclerView.setAdapter(myListAdapter);
Run Code Online (Sandbox Code Playgroud)

RecyclerView布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_height="match_parent"
android:layout_width="match_parent">

<FrameLayout
android:id="@+id/myFrameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.bittentech.hindinews.Fragments.HomeFragment">

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/mySwipeRefresh"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/myNestedScrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="true"
        app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <!-- TODO: Update blank fragment layout -->
            <android.support.v7.widget.RecyclerView
                android:id="@+id/myRecyclerView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <ProgressBar
                android:id="@+id/myProgress"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/myRecyclerView" />


        </RelativeLayout>

    </android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>



</FrameLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我的浏览者项目:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

4
推荐指数
1
解决办法
2599
查看次数

标签 统计

android ×1

android-recyclerview ×1