ImageView is not showing in dispaly cutout area in Samsung One UI Device

179 Views Asked by At

I am trying to make a fullscreen activity. I have edited theme style for my activity to show it in display cutout. But it's not working. I am trying this in my Samsung phone with One UI Pie, I have seen some questions on the stack and they may work in pixel or Stock Android. But they are not working in Samsung.

Here's the code.

This is my Style Code.

<style name="FullScreen" parent="Theme.AppCompat.Light">
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">true</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowTranslucentStatus">false</item>
        <item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="o_mr1">shortEdges</item>
    </style>

I have also tried it programmatically.


import androidx.appcompat.app.AppCompatActivity;

import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;

public class NotchEdit extends AppCompatActivity {
    private ImageView iv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notch_edit);

        ImageView iv = findViewById(R.id.imageView3);

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

but nothing works. in a image below you can see how it look.The Screenshot of activity

So Please tell me how to do it in Samsung device and also in other devices as well.

1

There are 1 best solutions below

0
On BEST ANSWER

Add this style for full screen activity :-

<style name="FullScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>