4

Here are two images taken in landscape mode. One is full screen mode and the other is normal mode. The issue I am trying to solve is how to color the left white area you see in the normal view. I'd like the color to be the same as the rest of the app. There is no concern with full screen view vs normal view in portrait mode which is working fine. The concern is only with landscape mode.

Has anyone had success in coloring the left hand side on a notched device in landscape mode?

An example of the the white area on the top and bottom of the left-hand notch. An example of the the white area on the top and bottom of the left-hand notch.

No concern with full-screen mode. Working fine. No concern with full-screen mode. Working fine.

Java42
  • 587
  • 5
  • 13
  • I came by the same problem, have you found a solution? Thank you – Ashraf Alshahawy Oct 14 '20 at 03:38
  • @AshrafAlshahawy I can't remember how we solved the problem ( or even if we did ). I'm going to pull the code from SVN and have a look. – Java42 Oct 16 '20 at 02:25
  • @AshrafAlshahawy Bad news - the bug is still there. Ugly white bar on left side cutout area. I can't believe I released that app with the bug. Anyway, I'm going to work on it a little and if I find a solution I'll update this item. Thanks for asking about it because it brought the problem back to my attention. – Java42 Oct 16 '20 at 02:39

2 Answers2

5

Here is a fix for @AshrafAlshahawy:

  1. Create a BitmapDrawable of your target color or image.
  2. Set that drawable on the activity's window.

Example:

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

Another Example:

    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);

Both tested in Activity.onCreate.

Java42
  • 587
  • 5
  • 13
  • 1
    Thank you Java42, it worked :) If you could add the answer to my question here https://stackoverflow.com/questions/64346864/activity-not-extended-below-the-cutout-in-landscape So I can reward you the 50 points, a simple token of appreciation. – Ashraf Alshahawy Oct 16 '20 at 13:58
  • 1
    Great. Glad to hear it worked for you. I updated that other question with the answer. – Java42 Oct 16 '20 at 23:58
-1

In your theme just add the color you want:

<item name="android:statusBarColor" tools:targetApi="l">@color/black</item>
Duna
  • 1,564
  • 1
  • 16
  • 36