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>