Roc*_*kin 10 android android-scrollview android-recyclerview android-nestedscrollview
我需要类似于此实现的行为但 NestedScrollView 将是父级, RecyclerView 将是 NestedScrollView 的子级。
例如:https : //medium.com/widgetlabs-engineering/scrollable-nestedscrollviews-inside-recyclerview-ca65050d828a
我不确定它是否可以实现。尝试在 child(RV) 滚动时禁用 parent(NSV),但是在 child 上滚动会滚动整个视图,包括 parent。
发布您迄今为止尝试过的全部内容。
你的xml应该是,
<android.support.v4.widget.NestedScrollView
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View > <!-- upper content -->
<!-- set recycler view with with wrap_content -->
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
在 onCreateView() / onCreate() 方法中设置滚动行为。需要 API 21+ 。
RecyclerView v = (RecyclerView) findViewById(...);
v.setNestedScrollingEnabled(false);
or
android:nestedScrollingEnabled="false" // inside recycler view in xml file
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3278 次 |
| 最近记录: |