Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>

like image 747
Prabhakar Pandey Avatar asked Dec 31 '25 21:12

Prabhakar Pandey


2 Answers

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.

like image 141
Amad Yus Avatar answered Jan 02 '26 09:01

Amad Yus


in your oncreate()

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

OR
in your manifest

<activity android:name=".MainActivity"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">

If your class extends ActionBarActivity then you can use

actionbar=getSupportActionBar();
actionbar.hide();
like image 23
Aditya Vyas-Lakhan Avatar answered Jan 02 '26 10:01

Aditya Vyas-Lakhan