Search code examples
androidandroid-studioandroid-actionbarandroid-fullscreenandroid-titlebar

How to hide title bar in Main Activity : I'm Using Android Studio


I'm Using Android Studio and tried everything possible by searching all the questions and answers available here and rest of the web. But nothing worked. Please assist me I'm new to android and very curios to learn.

Here is my XML code :

On using NoTitleBar.Fullscreen and any other theme. App is being crashed

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

<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<application

    android:theme="@style/AppTheme"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:persistent="true">

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:configChanges="keyboardHidden|orientation">

        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>


        </intent-filter>

    </activity>

</application>


Solution

  • May I know what is your Android Studio version? When you create the activity, you will have this value in your styles.xml

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

    Check on your res > values > styles.xml, add it if there is no value like above. Then go to your manifest, add android:theme="@style/AppTheme.NoActionBar" in your activity tag.

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:configChanges="keyboardHidden|orientation"
        android:theme="@style/AppTheme.NoActionBar">
        
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
    
    
        </intent-filter>
    
    </activity>
    

    For new version of Android Studio, styles.xml has been replaced to themes.xml.