Android 壁纸横屏显示一半黑屏

问题定位是 *大师手机APP 设置壁纸导致。

系统裁剪显示静态壁纸的类 SystemUI/src/com/android/systemui/ImageWallpaper.java 

        boolean updateSurfaceSize(SurfaceHolder surfaceHolder, DisplayInfo displayInfo,
                boolean forDraw) {
            boolean hasWallpaper = true;

            // Load background image dimensions, if we haven't saved them yet
            if (mBackgroundWidth <= 0 || mBackgroundHeight <= 0) {
                // Need to load the image to get dimensions
                loadWallpaper(forDraw);
                if (DEBUG) {
                    Log.d(TAG, "Reloading, redoing updateSurfaceSize later.");
                }
                hasWallpaper = false;
            }

            // Force the wallpaper to cover the screen in both dimensions

            // 这里是给定壁纸绘制范围,原生的会去判断取当前display和壁纸数值的最大值,修改强制按照 displayInfo 适配
            // int surfaceWidth = Math.max(displayInfo.logicalWidth, mBackgroundWidth);
            // int surfaceHeight = Math.max(displayInfo.logicalHeight, mBackgroundHeight);
            int surfaceWidth = displayInfo.logicalWidth;
            int surfaceHeight = displayInfo.logicalHeight;

            // Used a fixed size surface, because we are special.  We can do
            // this because we know the current design of window animations doesn't
            // cause this to break.
            surfaceHolder.setFixedSize(surfaceWidth, surfaceHeight);
            mLastRequestedWidth = surfaceWidth;
            mLastRequestedHeight = surfaceHeight;

            return hasWallpaper;
        }

三方APP也可以通过 extends WallpaperService ,使用系统接口去绘制图片。但是需要在 设置-显示-壁纸 中去修改壁纸设置应用。修改设置壁纸应用使用 WallpaperManagerService.java -> setWallpaperComponent(ComponentName name)。*大师手机APP设置为壁纸APP之后就出问题了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值