Bin*_*aby 5 android android-scrollview android-recyclerview nestedscrollview android-nestedscrollview
所以我有Recyclerview一个NestedScrollView. 当我说recycleview.scrollToPosition(X)或者recycleview.getLayoutManager().scrollToPosition(X)它根本不起作用时。
如果我recycleview从nestedScrollView它移出它工作正常,但我不能这样做,因为布局结构!任何的想法?
scrollingView.requestChildFocus(recyclerView,recyclerView);
Run Code Online (Sandbox Code Playgroud)
尝试过这个,但没有专注于某个位置
让你的回收视图像这样
<LinearLayout
android:id="@+id/ll2"
android:focusableInTouchMode="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:clipToPadding="false"
android:visibility="visible"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
和java代码
ItemsArrayList.add(0, items5);
adapter.notifyDataSetChanged();
ViewCompat.setNestedScrollingEnabled(recyclerView,false);
NestedScrollView nestedScrollingView = (NestedScrollView) findViewById(R.id.nestedScrollingView);
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.ll2);
float y = fcRecyclerView.getChildAt(0).getY();
float z =linearLayout.getY();
nestedScrollingView.smoothScrollTo(0, (int) z);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2973 次 |
| 最近记录: |