Reputation: 837
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
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" />
Upvotes: 8
Views: 24534
Reputation: 701
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)
}
}
Upvotes: 0
Reputation: 41
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"
Upvotes: 0
Reputation: 31
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.
Upvotes: 0
Reputation: 81
Kotlin: programmatically for API 21: Put it inside onCreate()
@TargetApi(21)
window.statusBarColor = Color.TRANSPARENT
Upvotes: 0
Reputation: 133
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?
Upvotes: 0
Reputation: 45042
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>
Upvotes: 1
Reputation: 468
Just add this in your style.xml:
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
Upvotes: 18
Reputation: 837
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
Upvotes: 2
Reputation: 1260
Just add this code in your activity onCreate()
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Upvotes: 0
Reputation: 60
Just add this to your onCreate()
method:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Upvotes: 3
Reputation: 507
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?
Upvotes: 2