Android 壁纸横屏显示一半黑屏
Posted 虫师魁拔
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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之后就出问题了。
以上是关于Android 壁纸横屏显示一半黑屏的主要内容,如果未能解决你的问题,请参考以下文章
Android : Google Maps API V2 显示黑屏 ECLIPSE