user4790312
user4790312

Reputation:

Android Hide actionbar and Toolbar

in manifest i use

minSdkVersion 14
targetSdkVersion 23

and now, i want to hide theme:

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

    <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:theme="@android:style/Theme.NoTitleBar.Fullscreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>


<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="@style/Theme.AppCompat.Light">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowActionBar">false</item>
    </style>

</resources>

but i get this error:

    Caused by: java.lang.IllegalStateException: You need to use a 
Theme.AppCompat theme (or descendant) with this activity.

Upvotes: 3

Views: 2977

Answers (3)

Kostas Drak
Kostas Drak

Reputation: 3260

Just replace this:

<style name="AppTheme" parent="@style/Theme.AppCompat.Light">

with this:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

and if you want to hide the toolbar after the setSupportActionbar(Toolbar toolBar) method use getSupportActionbar().hide();

Hope it helps!!!

Upvotes: 1

Pankaj
Pankaj

Reputation: 8058

Check my solution at this link

OR

Use style

<style name="FullScreenTheme" parent="Theme.AppCompat.NoActionBar">
    <!-- ... -->
</style>

Upvotes: 1

Arshid KV
Arshid KV

Reputation: 10037

Use getSupportActionBar().hide(); in activity.

Or getActivity.getSupportActionBar().hide(); in fragment .

Upvotes: 2

Related Questions