ActionBar isn't displaying in API 16

谁说胖子不能爱 提交于 2019-12-11 00:58:09

问题


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

Here is my 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

<?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>

回答1:


At first , According to your requirement please remove this line from manifest

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

My Suggestion , Use Toolbar instead of ActionBar .



来源:https://stackoverflow.com/questions/34453383/actionbar-isnt-displaying-in-api-16

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!