2017-03-31 25 views
-1

我有toolbar问题当我把他推上去时,viewpager也上去了,并且留下空间(见图)任何解决这个问题的办法。ViewPager被推上去的时候我按工具栏

这是我activity_main:

<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" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
android:background="#fafafb"> 
<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:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 
     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|enterAlways|snap" 
      android:elevation="5dp" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 
     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_below="@id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:tabMaxWidth="0dp" 
      app:tabGravity="fill" 
      app:tabMode="fixed" 
      app:tabIndicatorHeight="2dp" 
      android:elevation="10dp"/> 
    </android.support.design.widget.AppBarLayout> 
    <android.support.v4.view.ViewPager 
     android:id="@+id/viewpager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/tabs" 
     android:background="#fafafb" 
     android:layout_marginBottom="?attr/actionBarSize" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 
</android.support.design.widget.CoordinatorLayout> 

+0

查看传呼机内的布局是什么?你可以在这里发帖吗? –

回答

1

删除:

app:layout_behavior="@string/appbar_scrolling_view_behavior" 

从你ViewPager

的支持库包含映射到AppBarLayout.ScrollingViewBehavior特殊字符串资源@string/appbar_scrolling_view_behavior,这是使用在此特定视图上发生滚动事件时通知AppBarLayout

了解更多Clarification

+0

谢谢@ rafsanahmad007,但是当删除它没有任何改变,现在没有推工具栏底部的空间仍然显示 –

+0

您需要从viewpager删除底部边距:'android:layout_marginBottom =“?attr/actionBarSize”''。 – rafsanahmad007

+0

已经删除它,但在列表视图中的最后一项不显示 –