Android: creating a full-screen application

What is the easiest change I can make to the new Blank Activity created by the latest version of Android Studio so that the application appears in full screen mode?

I want to create a full screen Android app. I am working with Android Studio. This post assumes that I am adding 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 application compiles, but it crashes on startup. If I delete the line, the application works fine, but with an action bar and a title bar, which is also noted by other users.

This is my first attempt to create an Android application, so my application is unlikely to change from the original Hello World example.

EDIT: . :

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)...

. Samsung SGH-T499Y, Android 2.2 (Froyo)

+40
9

- , , android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"> to, ActionBarActivity, AppCompat.

Activity, ActionBarActivity

, Java-.

, setContentView(layout) in onCreateView method

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
+74

:

<item name="android:windowFullscreen">true</item>

:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/orange</item>
    <item name="colorPrimaryDark">@android:color/holo_orange_dark</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
</style>
+28

android:theme="@style/Theme.AppCompat.Light.NoActionBar"
+17

. . logcat. , logcat -, .

:

 public class ActivityName extends Activity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            // remove title
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
            setContentView(R.layout.main);
        }
 }
+9

android:windowIsTranslucent,

/styles.xml

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

    <style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <!-- to hide white screen in start of window -->
    <item name="android:windowIsTranslucent">true</item>
    </style>

</resources>

AndroidManifest.xml .

android:theme="@style/AppTheme"

<activity android:name=".Splash"
            android:theme="@style/AppTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
+8

, Android

1. styles.xml

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

2. AndroidManifest.xml

<activity
android:name='.Activity'
android:theme="@style/AppTheme.Fullscreen"/>

3. Java-

, onCreate().

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
+4

onCreate

requestWindowFeature(Window.FEATURE_NO_TITLE); // for hiding title

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                            WindowManager.LayoutParams.FLAG_FULLSCREEN);
+3

, onCreate

getWindow().getDecorView().setSystemUiVisibility(SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
        SYSTEM_UI_FLAG_FULLSCREEN | SYSTEM_UI_FLAG_HIDE_NAVIGATION   | 
        SYSTEM_UI_FLAG_LAYOUT_STABLE | SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
+2

, ( Rohit5k2 ):

https://bsgconsultancy.wordpress.com/2015/09/13/convert-any-website-into-android-application-by-using-android-studio/

3 MainActivity Activity ActionBarActivity ( Rohit5k2). NoTitleBar Fullscreen AndroidManifest.xml (. 4).

0

Source: https://habr.com/ru/post/1672979/


All Articles