我希望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>
答案 0 :(得分:0)
LinearLayoutManager linearLayoutManager =(LinearLayoutManager)recyclerView.getLayoutManager(); 如果(linearLayoutManager!= null){
linearLayoutManager.setSmoothScrollbarEnabled(true);
linearLayoutManager.scrollToPositionWithOffset(pos, 0);
}