简体   繁体   English

ActionBar未在API 16中显示

[英]ActionBar isn't displaying in API 16

I'm a beginner, I have made an app which contains navigation drawer along with the action bar in mainactivity.It worked perfectly on API 23 but in API 16, action bar isn't showing up.I searched many links on "actionbar not displaying" but they were having problems below API 11/8.After API 11, I think AppCompat should work (which I have used) Here are images 我是一个初学者,我制作了一个应用程序,其中包含导航抽屉以及mainactivity中的操作栏。它在API 23上运行良好,但在API 16中却没有显示操作栏。我在“ actionbar not显示”,但它们在API 11/8以下存在问题。在API 11之后,我认为AppCompat应该可以(我使用过)这是图像

在API 16上

在API 23上

Here is my styles.xml 这是我的styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat">
        <!-- 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" parent="Theme.AppCompat.NoActionBar">
        <item name="windowNoTitle">true</item>
    </style>
    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

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

</resources>

AndroidManifest.xml AndroidManifest.xml中

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.portus.yehchina">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            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=".RegistrationActivity"
            android:label="@string/title_activity_registration"
            android:theme="@style/AppTheme"></activity>
    </application>

</manifest>

At first , According to your requirement please remove this line from manifest 首先,根据您的要求,请从清单中删除此行

android:theme="@style/AppTheme.NoActionBar"

My Suggestion , Use Toolbar instead of ActionBar . 我的建议是,使用工具栏代替ActionBar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM