当我将FragmentPagerAdapter和ViewPager一起使用时,为什么在活动中看到两个工具栏?

智慧

在此处输入图片说明我想在一个Activity上创建ViewPager以显示我的片段。但我也想展示我的自定义工具栏。但是,我有两个工具栏和ViewPager。其中一个是我的自定义工具栏,另一个是默认工具栏。我声明了这样的主题android:theme =“ @ style / AppTheme.NoActionBar”

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.2">
    <android.support.v7.widget.Toolbar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/toolbarP015"
        android:background="@color/colorOfToolbar"/>
</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.8"
    android:id="@+id/viewPagerP015">

    <android.support.v4.view.PagerTabStrip
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:layout_gravity="top" />

</android.support.v4.view.ViewPager>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".P000Menu"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar"
        >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".P001CoordinatorLayout"
        android:theme="@style/AppTheme.NoActionBar"
        android:parentActivityName=".P000Menu">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".P000Menu">
        </meta-data>
    </activity>

    <activity android:name=".P002FragmentReview"/>

    <activity android:name=".P003TwoFragmentCommunication"/>

    <activity android:name=".P004FragmentProgrammatically"/>

    <activity android:name=".P005FragmentProg2"/>

    <activity android:name=".P006Fragmentv4"/>

    <activity android:name=".P007Fonts"/>

    <activity android:name=".P008HATAScrollingMagic"
        android:theme="@style/AppTheme.NoActionBar"/>

    <activity android:name=".P009DrawerLayoutNew"/>

    <activity android:name=".P010DrawerLayoutFull"
        android:theme="@style/AppTheme.NoActionBar"/>

    <activity android:name=".P011LayoutProgrammatically"/>

    <activity android:name=".P012TabHostReview"/>

    <activity android:name=".P013TabHostNew"/>

    <activity android:name=".P014ViewPagerTransforms"
        android:theme="@style/AppTheme.NoActionBar"/>

    <activity android:name=".P015ViewPagerPagerTabStrip"
        android:theme="@style/AppTheme.NoActionBar"/>
</application>

Dieter_h

更改AppBarLayout为:

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

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbarP015"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#6712FF" />
    </android.support.design.widget.AppBarLayout>

或删除AppBarLayout离开Toolbar

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

与AppBarLayout和折叠式工具栏一起使用时,ViewPager2的尺寸错误

将Android导航组件与片段内的单个活动,布局抽屉和工具栏一起使用

为什么与nvm一起使用时pnpm有两个商店?

为什么我在 Spark UI 中看到两个作业进行一次读取?

将工具栏与片段一起使用

将windowTranslucentStatus与隐藏的工具栏一起使用

将主工具栏与Mono一起使用

当我将 cbind 与来自 gsub 函数的对象一起使用时,为什么所有值都被引用?

当我将POSTMAN与x-www-urlencoded一起使用时,Jersey总是产生状态415!为什么?

与导航抽屉一起使用时,工具栏的后退按钮不起作用

将COUNT与OVER一起使用时,将两个参数与PARTITION BY一起使用是什么意思?

当我将 avg 与 count 和 sum 一起使用时,组函数的使用无效

当我将 [::-1] 与变量一起使用时会发生什么?

当将max函数与int和float vars一起使用时,Pycharm为什么会给我一个警告

将底部菜单栏与导航体系结构组件一起使用时,如何从工具栏中删除后退按钮

为什么我在update-alternatives --config java中看到两个Java路径

当我将OpenGL与glut一起使用时,为什么在关闭窗口并重新打开窗口时却什么也没显示?

在将getopts与case一起使用时:*)作为最后一个模式子句,或者将\\)和`:)作为最后两个模式子句?

我无法让 OnClickListeners 与包含两个不同片段的 Android 活动一起使用

NavigationDrawerFragment无法与AppCompat工具栏一起使用

在将Pipework与Docker容器一起使用时,为什么我无法进行RTNETLINK操作?

崩溃的工具栏和片段布局无法一起使用

将Tab与新工具栏一起使用(AppCompat v7-21)

将折叠式工具栏与基于片段元素的布局一起使用

如何将折叠工具栏与ListView而不是Recycler View一起使用

为什么我的主板不能与两个CPU一起工作?

为什么我的两个 html 内容不能一起工作

为什么我不能把这两个框架放在一起

当我将它包含在另一个活动中时,如何在自定义工具栏上使用图标?