Created
April 2, 2020 12:55
-
-
Save slightfoot/216e9da2dffa424e6f6229a66dce3c65 to your computer and use it in GitHub Desktop.
Draw Under System Ui in Flutter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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