Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 工具栏与“坐标布局”下的活动重叠_Android_Android Layout_Android Fragments - Fatal编程技术网

Android 工具栏与“坐标布局”下的活动重叠

Android 工具栏与“坐标布局”下的活动重叠,android,android-layout,android-fragments,Android,Android Layout,Android Fragments,在带有ViewPager和三个片段的活动中,我想自动隐藏工具栏。为此,我使用了android.support.design.widget.CoordinatorLayout 但是ViewPager给了我一些问题。如果它位于CoordinateLayout,则工具栏与活动重叠。如果在协调布局之外,则工具栏活动不会与网络视图活动重叠。如果ViewPager在CoordinatorLayout之外,则自动隐藏不起作用 任何帮助都将不胜感激 活动\u main.xml <LinearLayout

在带有
ViewPager
和三个片段的活动中,我想自动隐藏
工具栏
。为此,我使用了
android.support.design.widget.CoordinatorLayout

但是
ViewPager
给了我一些问题。如果它位于
CoordinateLayout
,则
工具栏与活动重叠。如果在
协调布局
之外,则
工具栏
活动不会与
网络视图
活动重叠。如果
ViewPager
CoordinatorLayout
之外,则自动隐藏不起作用

任何帮助都将不胜感激

活动\u main.xml

<LinearLayout 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"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <android.support.design.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/coordinatorLayout"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:fitsSystemWindows="true">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true">

            <android.support.v7.widget.Toolbar
                android:id="@+id/tool_bar"
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:background="@color/ColorPrimary"
                android:elevation="2dp"
                android:theme="@style/Base.ThemeOverlay.AppCompat.Dark"
                android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_scrollFlags="scroll|enterAlways"
                android:fitsSystemWindows="true" />

            <com.taadu.slidechat.adaptor.SlidingTabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/ColorPrimary"/>

        </android.support.design.widget.AppBarLayout>

        <android.support.v4.view.ViewPager
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        </android.support.v4.view.ViewPager>
    </android.support.design.widget.CoordinatorLayout>

</LinearLayout>

这是因为您将
layou行为
赋予您的
NestedScrollView
而不是您的
ViewPager

app:layout\u behavior=“@string/appbar\u scrolling\u view\u behavior”
添加到您的
ViewPage

您的
查看页面
应该是

<android.support.v4.view.ViewPager
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior>
</android.support.v4.view.ViewPager>

谢谢!!成功了!。
<android.support.v4.view.ViewPager
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior>
</android.support.v4.view.ViewPager>