Android 查看寻呼机未正确显示

Android 查看寻呼机未正确显示,android,Android,我第一次尝试实现一个视图寻呼机,但我的寻呼机选项卡显示视图 AppBar中片段的默认页面计数是屏幕截图 这是我的xml代码 <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="h

我第一次尝试实现一个视图寻呼机,但我的寻呼机选项卡显示视图 AppBar中片段的默认页面计数是屏幕截图

这是我的xml代码

 <?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"
          xmlns:tools="http://schemas.android.com/tools"
          android:id="@+id/drawer_layout"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"
          tools:openDrawer="start">
       <include
             layout="@layout/app_bar_main"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:id="@+id/appBar"/>

      <android.support.design.widget.NavigationView
            android:id="@+id/nav_view"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:fitsSystemWindows="true"
            app:headerLayout="@layout/nav_header_main"
            app:menu="@menu/activity_main_drawer" />

           <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@+id/appBar"
                android:clickable="true">
                <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.PagerTabStrip
                        android:id="@+id/pager_header"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="top"
                        android:layout_marginTop="30dp"
                        android:paddingBottom="4dp"
                        android:paddingTop="4dp"
                        />
                </android.support.v4.view.ViewPager>
           </RelativeLayout>
    </android.support.v4.widget.DrawerLayout>


请尝试为我提供一个可能的解决方案

加载项ViewPager
android:marginTop=“?attr/actionBarSize”
如下

<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:marginTop="?attr/actionBarSize" //change here
    >
    <android.support.v4.view.PagerTabStrip
        android:id="@+id/pager_header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:layout_marginTop="30dp"
        android:paddingBottom="4dp"
        android:paddingTop="4dp"
        />
</android.support.v4.view.ViewPager>

在相对布局中尝试以下代码

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMode="fixed"
            app:tabGravity="fill"/>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"  />