gpt4 book ai didi

android - 如何在非全屏横向模式下为切口/缺口区域着色

转载 作者:行者123 更新时间:2023-12-05 00:00:01 25 4
gpt4 key购买 nike

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

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

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.不用担心全屏模式。工作正常。

最佳答案

这是@AshrafAlshahawy 的修复:

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

例子:

    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 中进行了测试。

关于android - 如何在非全屏横向模式下为切口/缺口区域着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58896621/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com