Man*_*nos 12 android android-fragments android-recyclerview
我有一个折叠工具栏和嵌套滚动视图的活动FrameLayout,我将片段放在其中.最初,我FragmentA用CardView放入它.
效果很好.当我单击一个按钮时,我将其替换FragmentB为另一个包含RecyclerView的按钮.
当我添加FragmentBI cant滚动到列表的底部.
此视频显示了问题:链接到视频
主机活动布局:
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="340dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed|enterAlwaysCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
.........
......
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<!-- the layout which will be the content of the activity (which will be hosted inside the drawer (NOT the list of the drawer)) -->
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
</FrameLayout>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
FragmentB布局:
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/contentView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_users"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<include
layout="@layout/view_progress"
/>
<include
layout="@layout/view_retry"
/>
<!--</LinearLayout>-->
</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)
你把它RecyclerView放进去了NestedScrollView.
我认为更好的解决方案是拥有NestedScrollView或RecyclerView不是两者,因为RecyclerView已经在实施NestedScrollingChild.
我的应用程序中有类似的布局.我做了同样的事情 - 将RecyclerView放到FrameLayout然后放在NestedScrollView中.停止正常工作.没有NestedScrollView一切正常.
| 归档时间: |
|
| 查看次数: |
3100 次 |
| 最近记录: |