如何在非全屏横向模式下为 cutout/notch 区域着色

How can I color the cutout/notch area in non-full screen landscape mode

这是两张横向拍摄的照片。一种是全屏模式,另一种是普通模式。我要解决的问题是如何为您在普通视图中看到的左侧白色区域着色。我希望颜色与应用程序的其余部分相同。全屏视图与纵向模式下的正常视图无关,工作正常。问题仅在于横向模式。

有没有人成功地为横屏模式下的带槽口设备的左侧着色?

左侧凹槽顶部和底部的白色区域示例。

不用担心全屏模式。工作正常。

这是对@AshrafAlshahawy 的修复:

  1. 创建目标颜色或图像的 BitmapDrawable。
  2. 在 activity 的 window 上设置可绘制对象。

示例:

    Bitmap bitmap = Bitmap.createBitmap(24, 24, Bitmap.Config.ARGB_8888);
    bitmap.eraseColor(Color.MAGENTA);
    BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), bitmap);
    getWindow().setBackgroundDrawable(bitmapDrawable);

另一个例子:

    Bitmap bitmap = Bitmap.createBitmap(24, 24, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawColor(Color.MAGENTA);
    BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), bitmap);
    getWindow().setBackgroundDrawable(bitmapDrawable);

均在 Activity.onCreate 中进行了测试。

在您的主题中只需添加您想要的颜色:

<item name="android:statusBarColor" tools:targetApi="l">@color/black</item>