3

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>

Pei
  • 11,452
  • 5
  • 41
  • 45

3 Answers3

10

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.

Amad Yus
  • 2,856
  • 1
  • 24
  • 32
  • thanks ! This is what I was searching and some developers here already discussed it but I was not getting. Actually I was putting my code directly in Manifest ! But here came style folder ! we did it ! Thank yo so much ! – Prabhakar Pandey Sep 01 '16 at 10:12
  • In Android Studio Chipmunk (2021-2-1) I found the layout in app -> res -> themes -> themes.xml. This worked for me, thank you. – Jason Jul 21 '22 at 16:55
2

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();
Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96
  • Hi, @Aditya I was wanted to do it in xml because when using coding ..(Window.FEATURE_NO_TITLE) title was still blinking little while. I also manifest styling by android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" but it was not good going ! I did it by below given method ! Thanks for taking your time to solve it :) 1st solution is also working :) – Prabhakar Pandey Sep 01 '16 at 10:16
  • Glad happy coding :) – Aditya Vyas-Lakhan Sep 01 '16 at 10:25
1

Android Studio 3.0

Go into res Folder and then Values Folder and open Styles.xml and change the AppTheme like following:

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

Here is the screenshot attached: enter image description here

Zulqarnain Mustafa
  • 1,615
  • 2
  • 22
  • 25