How to make FullScreen Activity on Android

So, I'm trying to reproduce the appearance of the Muzei Live Wallpaper application from Roman Nurik, which is open source.

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

When the application starts, a subtle SVG trace animation appears in the background, as well as the Ken Burns effect.

You may notice that the activity goes to the status bar and navigation bar.

I managed to achieve background animation, but I could not figure out how to make the exercise full-screen, as shown in the second GIF below.

I need help to make this action fullscreen / erase in the status bar and navigation bar.

That's what I was able to achieve.

Here's what I have been able to achieve

,

This what I want to implement

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" />
+5
7

, , . .

Post API 21 , -

getWindow().setStatusBarColor(Color.TRANSPARENT);

Android, xml /res/values -v21/styles.xml

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

enter image description here

+1

.xml:

<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
+14

, :

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

Source: Fullscreen on Android?

+2
source

Just add this to your method onCreate():

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
+2
source

Just add this code to your onCreate () activity

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
0
source

use @ style / Theme.AppCompat.Light.NoActionBar if you use the AppCompat action

 <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>
0
source

You can do this programmatically:

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: full-screen activity in Android?

0
source

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


All Articles