0

I am not able to make a fullscreen android app. Even though my mainactivity does not show the notification bar, but it keeps the area of notification bar empty... its like a padded white row the height of the notification bar. Any help would be appreciated. Here is my manifest file.

<application
   android:allowBackup="true"
   ...
   android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="landscape"
        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=".LoginActivity"
        android:screenOrientation="landscape"
        android:label="@string/title_activity_login"></activity>
</application>

If i make the modification

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

then it crashes my app, though it the app gets compiled.

UPDATE More detail. The error I get when the app crashes is:

**java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.vibha.digits42c/com.example.vibha.digits42c.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.**
                                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                               at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                               at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                               at android.os.Looper.loop(Looper.java:148)
                                                                               at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                               at java.lang.reflect.Method.invoke(Native Method)
                                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                            **Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.**
                                                                               at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:310)
                                                                               at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:279)
                                                                               at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:253)
                                                                               at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
                                                                               at com.example.vib.digits42c.MainActivity.onCreate(MainActivity.java:45)

Now at the last line @ MainActivity.java:45, the code is

setContentView(R.layout.activity_main);

I am targeting at Nexus 5, Android 6.0.1

user1517108
  • 2,395
  • 6
  • 32
  • 43
  • @onik Not really. I tried the answer but it does not work. I can 'make project' but when I run it the android prompts unfortunately the program has stopped'. However if I keep the oriiginal line then everything works smoothly but for the fullscreen part. – user1517108 Jan 24 '16 at 21:48
  • Then you probably should clearly state the issue in question if you'd like to get it resolved. – Onik Jan 24 '16 at 21:50
  • Still not clear. Please, post the stacktrace. – Onik Jan 24 '16 at 21:55
  • Its also relevant if you can include which version of Android you are targeting and testing on. – Maks Jan 24 '16 at 22:02
  • @Onik Dont know what stacktrace is as I am compllete newbie to this. Posted what I thought might be relevant. – user1517108 Jan 24 '16 at 22:04
  • @Maks updated my answer – user1517108 Jan 24 '16 at 22:04
  • 1
    Do like it's said: `java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.**`... or, if it's irrelevant, use `Activity` instead of `AppCompatActivity` and leave `@android:style/Theme.NoTitleBar.Fullscreen`. – Onik Jan 24 '16 at 22:09

1 Answers1

0

Instead of

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

try to use:

 android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

Hope it work

EDIT: Your java class extends Activity, should AppCompatActivity Change it

piotrek1543
  • 19,130
  • 7
  • 81
  • 94