【发布时间】:2019-03-06 12:30:22
【问题描述】:
我希望 recyclerview 从第 10 行开始。我在哪里犯了错误。它可能与 NestedScrollView 相关吗?会不会是与 NestedScrollView 相关的东西?
KuranFragment.java
ayetlerAdapter = new AyetlerAdapter(getContext(),ayetlerList,veri);
recyclerView.scrollToPosition(10);
recyclerView.setAdapter(ayetlerAdapter);
fragment_kuran.xml
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:id="@+id/nestedScrollView"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center"
android:textColor="@color/colorPrimary"
android:background="@drawable/sureheader2"
android:id="@+id/sureAd"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/sureAd"
android:orientation="horizontal">
<Switch
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/switchTR"
android:text="TR"/>
<Switch
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/switchAR"
android:text="AR"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="50dp"
android:id="@+id/rvAyetler" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
【问题讨论】:
-
我希望 recyclerview 从第 10 行开始?你能解释一下吗?
-
我希望在加载 recyclerview 时从第 10 行自动开始滚动
-
看看this
-
您是否尝试过先设置适配器然后滚动到位置?
recyclerView.setAdapter(ayetlerAdapter); recyclerView.scrollToPosition(10); -
是的,我试过了,但还是不行
标签: android android-recyclerview scroll