Skip to content

Instantly share code, notes, and snippets.

@pishguy
Forked from slightfoot/MainActivity.java
Created April 16, 2020 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pishguy/b2f70751af15ab35f70809874cd5307d to your computer and use it in GitHub Desktop.
Save pishguy/b2f70751af15ab35f70809874cd5307d to your computer and use it in GitHub Desktop.
Transparent Navigation in #Flutter App. 13th May 2019
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
drawUnderSystemUi();
}
@Override
protected void onPostResume() {
super.onPostResume();
drawUnderSystemUi();
}
private void drawUnderSystemUi()
{
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
Window window = getWindow();
window.setStatusBarColor(0x22000000);
window.setNavigationBarColor(0x22000000);
window.getDecorView()
.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment