8

Ok so I am trying to replicate the look and feel of the Muzei Live Wallpaper App by Roman Nurik which is open source.

(Check out his GitHub repository here - https://github.com/romannurik/muzei/ )

When the App Launches there is a subtle svg path tracing animation along with a Ken Burns effect that goes on in the background.

You can notice that the activity bleeds into the Status Bar and Navigation Bar.

I've been able to achieve the background animation but haven't been able to figure out how to make the activity full screen like shown in the 2nd GIF below

I need help making this activity fullscreen/ bleed into the status bar and navigation bar.

Here's what I have been able to achieve

Here's what I have been able to achieve

This what I want to implement

This what I want to implement

Here's my code

MainActivity.Java

package devexchanges.info.kenburnview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.Toast;

import com.flaviofaria.kenburnsview.KenBurnsView;
import com.flaviofaria.kenburnsview.RandomTransitionGenerator;
import com.flaviofaria.kenburnsview.Transition;


public class MainActivity extends AppCompatActivity {

    private KenBurnsView kenBurnsView;
    private boolean isPlay = true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        kenBurnsView = (KenBurnsView) findViewById(R.id.image);


        AccelerateDecelerateInterpolator ACCELERATE_DECELERATE = new AccelerateDecelerateInterpolator();
        RandomTransitionGenerator generator = new RandomTransitionGenerator(11000, ACCELERATE_DECELERATE);
        kenBurnsView.setTransitionGenerator(generator); //set new transition on kenburns view

        kenBurnsView.setTransitionListener(onTransittionListener());

    }

    private KenBurnsView.TransitionListener onTransittionListener() {
        return new KenBurnsView.TransitionListener() {

            @Override
            public void onTransitionStart(Transition transition) {
                //Toast.makeText(MainActivity.this, "start", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onTransitionEnd(Transition transition) {
                //Toast.makeText(MainActivity.this, "end", Toast.LENGTH_SHORT).show();
            }
        };
    }
}

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.flaviofaria.kenburnsview.KenBurnsView
        android:id="@+id/image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/saigon"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <Button android:background="@drawable/circle_button"
        android:layout_height="@dimen/intro_activate_button_size"
        android:layout_width="@dimen/intro_activate_button_size"
        android:text="ACTIVATE"
        android:textAllCaps="true"
        android:fontFamily="sans-serif-condensed"
        android:textStyle="bold"
        android:textSize="18dp"
        android:textColor="#333"
        android:id="@+id/activate_muzei_button"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="103dp"
        android:elevation="2dp" />
Prateek Prasad
  • 827
  • 2
  • 10
  • 19
  • Possible duplicate of [Fullscreen Activity in Android?](https://stackoverflow.com/questions/2868047/fullscreen-activity-in-android) – Rupam Das Jan 25 '18 at 20:14

11 Answers11

18

Just add this in your style.xml:

<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
AZZ_B
  • 428
  • 5
  • 15
3

Just add this to your onCreate() method:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
Samuel
  • 60
  • 11
2

To make an activity fullscreen put this in your manifest:

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

Source: Fullscreen Activity in Android?

Community
  • 1
  • 1
king
  • 507
  • 1
  • 4
  • 17
  • this is how you should do, the other ways should work, but this is the recommended way – Max Pinto Feb 20 '16 at 17:45
  • @king I was developing a react-native application, and this worked. If anyone is looking for solution in react-native make sure that app either ejected from create-react-native-app or it is created with react-native cli, else the AndroidManifest.xml will not be available for modification. – Priyank Thakkar Jun 14 '18 at 14:53
  • does nothing for me except add bloat. – RealTechyGod Nov 02 '20 at 21:27
2

Well turns out there is a simple solution to the problem. I just needed to make the status bar and navigation bar transparent.

Post API 21 we can do it programmatically like this -

getWindow().setStatusBarColor(Color.TRANSPARENT);

for making it work on lower android versions, I just needed to add the transparency via xml in the /res/values-v21/styles.xml

<item name="android:statusBarColor">@android:color/transparent</item>

Here's the final effect

enter image description here

Prateek Prasad
  • 827
  • 2
  • 10
  • 19
1

use @style/Theme.AppCompat.Light.NoActionBar if you are using AppCompat activity

 <activity android:name=".view.activity.SplashActivity"
                  android:theme="@style/Theme.AppCompat.Light.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
Hitesh Sahu
  • 41,955
  • 17
  • 205
  • 154
0

Just add this code in your activity onCreate()

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Arshad
  • 1,262
  • 16
  • 25
  • What you have got in your logcat on crash? Where you have added this code? Add this line of code after setContentView – Arshad Feb 20 '16 at 15:25
0

You can do it programatically:

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);
    }
}

Read This Content: Fullscreen Activity in Android?

Tarik Billa
  • 137
  • 1
  • 4
0

Kotlin: programmatically for API 21: Put it inside onCreate()

@TargetApi(21)
 window.statusBarColor = Color.TRANSPARENT
XploitsR
  • 51
  • 1
  • 4
0

In 2021 all codes are either deprecated or not working. For example:

View decorView = getWindow().getDecorView();
    decorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                    // Set the content to appear under the system bars so that the
                    // content doesn't resize when the system bars hide and show.
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    // Hide the nav bar and status bar
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN);

every line deprecated. some other some need API level R. So use style.

Search some time on google I found

<style name="FullScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/design_default_color_primary</item>
    <item name="colorPrimaryDark">@color/design_default_color_primary_dark</item>
    <item name="colorAccent">@color/teal_200</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowBackground">@color/white</item>
</style>

now use this style in the Manifest file

 <activity
        android:name=".FullScreenActivigy"
        android:theme="@style/FullScreenTheme"/>

I am using this block of code in my production app which is starts from API 21 to 30. work fine. Even user interact with their SMS or notification. when they back to my app it become full screen again.

0

If you're in the latest version of android in themes.xml change it to

parent="Theme.MaterialComponents.DayNight.DarkActionBar"

to

parent="Theme.MaterialComponents.DayNight.NoActionBar"
0
      override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
  val windowInsetsController =
            WindowCompat.getInsetsController(window, window.decorView)
        windowInsetsController.systemBarsBehavior =
            WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
        window.decorView.setOnApplyWindowInsetsListener { view, windowInsets ->
            windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
            view.onApplyWindowInsets(windowInsets)
        }
 }
Kumar Santanu
  • 603
  • 1
  • 7
  • 14