关于布局中的问题 多谢
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways|snap" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="@drawable/ic_done" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/nav_menu"
app:headerLayout="@layout/nav_header" />
</android.support.v4.widget.DrawerLayout>
这个布局 最外层是DrawerLayout的滑动菜单 ,里面第一个子控件是主屏幕中的内容,第二个子控件是一个NavigationView是滑动出来的内容。
主屏幕中的内容最外层是CoordinatorLayout 里面有一个Toolbar放在了AppBarLayout中,还有一个RecyclerView放在了SwipeRefreshLayout中。
我的问题是:原来没有用SwipeRefreshLayout的时候RecyclerView是这么写的:
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
当加入到SwipeRefreshLayout时 书上说因为RecyclerView是SwipeRefreshLayout的子控件,所以app:layout_behavior="@string/appbar_scrolling_view_behavior"要移动到SwipeRefreshLayout中才行,我试了试不移动确实会卡住,但是Toolbar不也是在AppBarLayout中吗?也是AppBarLayout的子控件吧 那么
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways|snap"
为什么不需要移动到AppBarLayout中呢?
如果移动过去 就没有原来的效果了 为什么不能移动过去啊?
多谢指教