Android 工具栏未使用协调器布局隐藏
我试图复制中讨论的行为,当我向下滚动一个RecyclerView(在一个单独的片段中)时,工具栏将隐藏,选项卡仍保留 不幸的是,在玩了很多次之后,我似乎无法移动工具栏,只是保持静止。我已经为我的活动和片段附加了XML 谢谢你的帮助,如果你需要更多的代码,尽管问吧 活动Android 工具栏未使用协调器布局隐藏,android,android-fragments,Android,Android Fragments,我试图复制中讨论的行为,当我向下滚动一个RecyclerView(在一个单独的片段中)时,工具栏将隐藏,选项卡仍保留 不幸的是,在玩了很多次之后,我似乎无法移动工具栏,只是保持静止。我已经为我的活动和片段附加了XML 谢谢你的帮助,如果你需要更多的代码,尽管问吧 活动 <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://sche
<?xml version="1.0" encoding="utf-8"?>
<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/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/topToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways" />
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/navigation_drawer_menu" />
</android.support.v4.widget.DrawerLayout>
片段:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.test.redditclient.Fragment_Posts">
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerList"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
<TextView
android:id="@+id/no_posts_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="@string/no_posts"
android:textAppearance="?android:attr/textAppearanceMedium"
android:visibility="gone" />
<fragment
android:id="@+id/bottom_toolbar"
android:name="info.test.redditclient.Fragment_Bottom_Toolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
tools:layout="@layout/fragment_bottom_toolbar"></fragment>
</RelativeLayout>
编辑:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.test.redditclient.Fragment_Posts">
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerList"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
<TextView
android:id="@+id/no_posts_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="@string/no_posts"
android:textAppearance="?android:attr/textAppearanceMedium"
android:visibility="gone" />
<fragment
android:id="@+id/bottom_toolbar"
android:name="info.test.redditclient.Fragment_Bottom_Toolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
tools:layout="@layout/fragment_bottom_toolbar"></fragment>
</RelativeLayout>
在提出了一些建议之后,对于我的活动布局,我将viewpager移到了AppBarLayout之外,并删除了一个redudant framelayout。问题仍然存在。将视图寻呼机移到AppBarLayout之外问题已解决: 我使用的是22.2.0之前的RecyclerView,它不起作用 我通过改变Gradle的外形解决了这个问题:
compile 'com.android.support:recyclerview-v7:22.2.0'
是否将片段添加到id为“container”的框架布局中?抱歉,没有。这是我的NavigationDrawer的容器。这些片段是使用我的定制寻呼机适配器添加的,这绝对不应该出现在那里。然而,它并没有解决我的问题。实际上,它将我的晶圆厂从另一个稍微远离屏幕的片段中移出<代码>23.0.0是最新版本。