android - 片段中滚动视图内的 RecyclerView 不起作用?
问题描述
我对recyclerview 有疑问。实际上,它在 Activity 上工作,没有任何滞后,但不在scrollview或nestedscrollview内的片段上。我已经对它进行了几次实验,但所有这些实验都只是让我进入了滞后的回收站视图。然后我使用了 Appbarlayout 行为,几乎我已经实现了平滑的 recyclerview,但是当我滚动到底部时,当我回到顶部并想要滚动回到底部时,不起作用。发生了什么问题?请帮我解决这个问题。
我的代码 FragmentHome.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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="match_parent">
<!-- Latest Images -->
<LinearLayout
android:id="@+id/latestPost"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<com.makeramen.roundedimageview.RoundedImageView
android:layout_width="4dp"
android:layout_height="match_parent"
android:layout_marginBottom="2dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="2dp"
android:scaleType="centerCrop"
android:src="@color/gradient_color_1"
app:riv_corner_radius="2dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/font_reg"
android:text="Latest Post"
android:textColor="@color/black"
android:textSize="18sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView_latest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<fr.castorflex.android.circularprogressbar.CircularProgressBar
android:id="@+id/pb_home"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:indeterminate="true"
android:visibility="gone"
app:cpb_color="#FFee44"
app:cpb_colors="@array/pocket_bar_colors"
app:cpb_max_sweep_angle="300"
app:cpb_min_sweep_angle="10"
app:cpb_rotation_speed="1.0"
app:cpb_stroke_width="4dp"
app:cpb_sweep_speed="1.0" />
</RelativeLayout>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
app:liftOnScroll="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_scrollFlags="scroll|enterAlways">
<LinearLayout
android:id="@+id/ll_home_featured"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/vp_home"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="10dp" />
<com.rd.PageIndicatorView
android:id="@+id/pageIndicatorView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="10dp"
app:piv_animationType="color"
app:piv_autoVisibility="true"
app:piv_dynamicCount="true"
app:piv_interactiveAnimation="true"
app:piv_padding="4dp"
app:piv_radius="5dp"
app:piv_selectedColor="@color/vp_indicator"
app:piv_unselectedColor="#B5B5B7"
app:piv_viewPager="@id/vp_home" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_home_pop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/iv2"
android:layout_width="4dp"
android:layout_height="match_parent"
android:layout_marginBottom="2dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="2dp"
android:scaleType="centerCrop"
android:src="@color/gradient_color_1"
app:riv_corner_radius="2dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/font_reg"
android:text="@string/popular_quotes"
android:textColor="@color/black"
android:textSize="18sp" />
<TextView
android:id="@+id/tv_no_pop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/font_light"
android:text="10 Quotes"
android:textSize="12sp" />
</LinearLayout>
<android.support.v7.widget.AppCompatButton
android:id="@+id/button_all_popular"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:fontFamily="@font/font_reg"
android:text="@string/more"
android:textColor="@color/white"
app:backgroundTint="@color/gradient_color_1" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_width="30dp"
android:layout_height="200dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:background="@drawable/bg_gradient_white" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_home_popular"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
解决方案
推荐阅读
- amazon-web-services - 在 Amazon Web Services S3 中保护存储桶和资源访问?
- ssl - nginx 和 bitnamis dockerized osclass 的 HTTP/HTTPS 重定向问题
- java - 无法创建自定义 BOM。项目构建失败并出现不可解析的导入 POM:找不到工件
- mysql - QMSQL:不能将不兼容的 Qt 库(版本 0x50b03)与此库(版本 0x50c05)混合
- reactjs - 在 @formatjs/intl-relativetimeformat/dist/locale-data/ 中哪里可以找到美国的语言环境
- mysql - 如何分组分组
- pandas - Pandas merge_asof() 给出重复匹配
- c# - AutoMapper 复制 EF 连接的对象,无需一行和几行代码
- angular - 如何使用隐藏和显示动态值来隐藏离子3中的值
- vb.net - IF报表中如何更改日期