【发布时间】:2015-06-24 17:32:43
【问题描述】:
我的活动中有以下代码:
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="160dp">
<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">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
</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:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</android.support.v4.widget.NestedScrollView>
我想在框架布局(“main_content”id 布局)中添加一个内部带有 RecyclerView 的片段,但在这种情况下,这不起作用。
有什么问题?你知道一些例子吗?
【问题讨论】:
-
查看本指南inthecheesefactory.com/blog/… 看看是否有帮助
-
“它不起作用”没有任何意义。
-
你不应该在另一个也有自己滚动视图的视图中拥有一个拥有自己滚动视图的视图,但看看这个答案是否对你有帮助nested scroll view
-
我想使用fragment将它们注入framelayout,我需要在我所有的fragment中创建AppBarLayout结构而不是在Activity布局中吗?
-
您不应该在 NestedScrollView 中添加 RecyclerView(仅使用其中一个)。我建议使用 ViewPager 之类的东西来嵌套您的片段。这是一个例子:github.com/blackcj/DesignSupportExample
标签: android android-recyclerview