What is the simplest change that I can make to a new Blank Activity, as created by the latest version of Android Studio, to get the app to appear fullscreen?
I want to create a fullscreen Android application. I'm working with Android Studio. This post suggests that I add a line such as ...
android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"
... to the AndroidManifest.xml file, as shown below:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lexogram.james.blackslate" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.lexogram.james.blackslate.MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
When I do this, the app compiles but it crashes on launch. If I remove the line, the app runs fine, but with the action bar and a title bar, as also noted by other users.
This is my first attempt at creating an Android app, so my app is hardly altered from the original Hello World example.
EDIT: I created a new project, and made just this one change to it. Here is an extract from the error log:
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lexogram.james.test/com.lexogram.james.test.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)...
NOTE: I am testing on a old Samsung SGH-T499Y, running Android 2.2 (Froyo)
Update Answer I added
android:windowIsTranslucent
in case you have white screen in start of activityjust create new Style in values/styles.xml
from your AndroidManifest.xml add style to your activity
android:theme="@style/AppTheme"
to be like this
You can use the following codes to have a full page in android
Step 1 : Make theme in styles.xml section
Step 2 : Add theme on AndroidManifest.xml
Step 3 : Java codes section
For example you can added following codes in to the onCreate() method.
You are getting this problem because the activity you are trying to apply the
android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
to is extending ActionBarActivity which requires the AppCompat theme to be applied.Extend your activity from
Activity
rather than fromActionBarActivity
You might have to change your Java class accordingly little bit.
If you want to remove status bar too then use this before
setContentView(layout)
inonCreateView
methodI recently had the exact same issue and benefitted from the following post as well (in addition to Rohit5k2's solution above):
https://bsgconsultancy.wordpress.com/2015/09/13/convert-any-website-into-android-application-by-using-android-studio/
In Step 3,
MainActivity
extendsActivity
instead ofActionBarActivity
(as Rohit5k2 mentioned). Putting theNoTitleBar
andFullscreen
theme elements into the correct places in theAndroidManifest.xml
file is also very important (take a look at Step 4).Just add the following attribute to your current theme:
For example:
in my case all works fine. See in logcat. Maybe logcat show something that can help you to resolve your problem
Anyway you can try do it programmatically: