feat: enable edge-to-edge mode and make status bar transparent in MainActivity
All checks were successful
Build Android APK / build (push) Successful in 6m25s
All checks were successful
Build Android APK / build (push) Successful in 6m25s
This commit is contained in:
@@ -1,15 +1,35 @@
|
||||
package es.dariosevilla.impostor;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
import com.getcapacitor.BridgeActivity;
|
||||
|
||||
public class MainActivity extends BridgeActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// Disable edge-to-edge to prevent status bar overlap
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
|
||||
|
||||
Window window = getWindow();
|
||||
|
||||
// Enable edge-to-edge mode so CSS safe-area-inset-* values work correctly
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false);
|
||||
|
||||
// Make status bar transparent so content can draw underneath
|
||||
window.setStatusBarColor(Color.TRANSPARENT);
|
||||
window.setNavigationBarColor(Color.TRANSPARENT);
|
||||
|
||||
// Set status bar icons to light (for dark backgrounds) or dark (for light backgrounds)
|
||||
WindowInsetsControllerCompat insetsController = WindowCompat.getInsetsController(window, window.getDecorView());
|
||||
if (insetsController != null) {
|
||||
// Use dark icons (false = dark icons for light status bar background)
|
||||
// The CSS handles the actual content offset via safe-area-inset-top
|
||||
insetsController.setAppearanceLightStatusBars(false);
|
||||
insetsController.setAppearanceLightNavigationBars(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user