【发布时间】:2018-04-10 00:42:19
【问题描述】:
我有一个活动,其中包括一些文本视图和一个 recyclerView,其中包含使用 Glide 显示的图像。我有一个问题,recyclerview 有自己不需要的滚动条。
然后我在 RecyclerView xml 中添加了这个:android:nestedScrollingEnabled="false"
根据RecyclerView need to scroll along the activity
现在 recyclerview 正在随着活动滚动,但现在还有另一个问题。并非所有图像都可见。看起来 RecyclerView 在膨胀时不知道其中所有图像的大小。我正在使用 Glide 来显示图像,并且图像项的大小固定为 250dp。
如果我删除了nestedScrollingEnabled 属性,那么所有图像都是可见的,但我需要在该recyclerView 内滚动。
这是我的回收站视图
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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_width="fill_parent"
android:layout_height="fill_parent">
<android.support.constraint.ConstraintLayout 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:id="@+id/activity_prikazi_vest"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin1"
android:paddingRight="@dimen/activity_horizontal_margin1"
android:paddingTop="@dimen/activity_horizontal_margin1"
android:scrollbars="vertical"
tools:context="myapp.app.news">
----------------here are some textviews----------------------
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_images"
android:nestedScrollingEnabled="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:scrollbars="none"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
这是我用于 Glide 的设置
RequestOptions options = new RequestOptions()
.centerCrop()
.placeholder(R.drawable.image1)
.error(R.drawable.image2)
.priority(Priority.HIGH);
更新:
要平滑滚动,请在 recyclerview 中使用它
android:nestedScrollingEnabled="false"
android:isScrollContainer="false"
【问题讨论】:
-
你能给我看看你的视图持有者 xml 吗?
-
我已编辑问题
-
你能给我看看项目的xml吗?我的意思是 xml inflate(R.layout.blalba)
-
您可以尝试将
android.support.constraint.ConstraintLayout删除为Relative Layout,并且不要忘记删除您的xml 中的所有约束属性。
标签: android android-recyclerview android-glide