【发布时间】:2019-04-27 17:06:47
【问题描述】:
我在nestedsrcollview 下有一个recyclerview。我想为 recyclerview 实现滚动到特定位置,但我遇到了困难。 xml代码为:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".HomeFragment"
android:background="#ffffff"
android:fillViewport="true"
android:id="@+id/nestedscrollview"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:orientation="vertical"
>
<<some other layouts>>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/home_blog_list"
android:layout_marginBottom="52dp"
/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
我想实现 home_blog_list recyclerview 的滚动定位到一个位置(比如 26)。怎么做? P.S.-我已将 home_blog_list 的 nestedscrollingenabled 设置为 false。请注意,我想将 nestedscrollview 滚动到 recyclerview 的特定行。我不想要只滚动recyclerview 的情况。提前致谢!
【问题讨论】:
-
不,它没有用。我实际上正在滚动nestedscrollview。回收站视图就在里面。如何将nestedscrollview滚动到recyclerview里面的特定位置?
-
为什么需要嵌套滚动视图。 recyclerview 是可滚动的。如果你同时实现嵌套的scrollview 和recyclerview,它会在滚动时导致很多问题。
-
实际上我的布局中还有另一个recyclerview(这个是水平的)。我希望整个系统滚动。 (就像 instagram 中的状态 recyclerview 和帖子 recyclerview 一样)。
标签: android android-recyclerview android-nestedscrollview