Android API < 35 full screen app confusion

I’m working on an Android app (home project) written in Java. I’m a casual Android developer and in order to achieve full-screen functionality I applied the same steps I successfully used couple of years ago:

  1. Change the theme:
<style name="Base.Theme.MyApp" parent="Theme.Material3.Light.NoActionBar">
    <item name = "android:windowActionBar">false</item>
    <item name = "android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowLightStatusBar">false</item>

</style>

<style name="Theme.MyApp" parent="Base.Theme.MyApp" />
  1. Main activity (extending FragmentActivity, the only activity I have since I’m using fragments):
protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         EdgeToEdge.enable(this); //apparently for API 35+ this is the only thing I need
 
         View decorView = getWindow().getDecorView();
         int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
         decorView.setSystemUiVisibility(uiOptions);
 
         setContentView(R.layout.activity_main);
         ... }

The problem is, when testing this on API 34, my app is kind of full screen. There’s a thin black line on top where system bar should be. Also, Play Store gave me a warning I’m using deprecated methods for full screen view.
In order to resolve that I went through Google documentation, realized there are different methods for API versions 29 – 35 (my min SDK supported is 25) but apparently I couldn’t understand implementation properly as whenever I tried solutions from the Google docs – black line either stayed or app became full-screen with system bar drawn over top part of my app. I tried using insets and margins as Google docs suggested but it gave no results.
I was so desperate I even asked GTP for the solution and, obviously, I got speculative and non-working “solutions” and “ideas”.

Can you please help me with this? How to implement a proper full-screen support that works for API versions 29-35?

It’s incredible such a trivial every-day thing as showing app in full screen mode with no other elements on the screen is so elaborate and requires more code than setting a mere property of the activity hahah

EDIT:
This is the latest attempt I tried:

super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        EdgeToEdge.enable(this);

        Window window = getWindow();
        View decorView = getWindow().getDecorView();

        WindowCompat.setDecorFitsSystemWindows(window, false);
        WindowInsetsControllerCompat controllerCompat = new WindowInsetsControllerCompat(window, decorView);
        controllerCompat.hide(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.navigationBars());
        controllerCompat.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);

and the result I get (top of the screen):

I have also removed anything from my themes.xml, theme parent is just Theme.Material3.Light.NoActionBar

2

Ok, solved! For anyone having the same problem – I figured it out. So:

I used an emulator without front and back cameras but when I switched the skin to Pixel 5 I realized that black line height perfectly corresponds to front camera height. I continued digging deeper and found out that using this code in “onCreate” method:

decorView.setOnApplyWindowInsetsListener((v, insets) -> {
            return insets.consumeSystemWindowInsets(); // Consume all insets to avoid unexpected padding
        });

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
            WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
            layoutParams.layoutInDisplayCutoutMode =
                    WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
            getWindow().setAttributes(layoutParams);
        }

forces Android to extend the activity all the way, even if it means certain parts of the UI might be obscured by the front camera. Now it works! 🙂

P.S.
IDK why it’s so hard for Android to understand when I say “full screen” with no other options specified, I want THE full screen even if it has consequences in the form of parts of hardware obstructing the UI… 🙂

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật