【问题标题】:Android Set Live Wallpaper to support both Landscape and Portrait modeAndroid 设置动态壁纸支持横向和纵向模式
【发布时间】:2013-12-04 12:16:00
【问题描述】:

如何设置适合横向和纵向模式的壁纸? 我使用的代码仅将动态壁纸设置为纵向或横向的一种模式。 假设如果我将墙纸设置为纵向模式并转到主屏幕并将方向更改为横向,则墙纸在横向模式下仅适合屏幕的一半,而另一半则显示空白屏幕。 请帮助我。

WallpaperManager wallpaperManager =WallpaperManager.getInstance(getBaseContext()); 
DisplayMetrics metrics = new DisplayMetrics(); 
getWindowManager().getDefaultDisplay().getMetrics(metrics); 
int height = metrics.heightPixels; 
int width = metrics.widthPixels;
Bitmap wallpaper = Bitmap.createScaledBitmap(bitmap1,width,height, true);
Canvas canvas = new Canvas(wallpaper);
imageView.draw(canvas);
textView.draw(canvas);
try {
wallpaperManager.setBitmap(wallpaper);
wallpaperManager.suggestDesiredDimensions(width,height);
}
catch (IOException e) {
Toast.makeText(FullImageActivity.this,
"Error setting wallpaper", Toast.LENGTH_SHORT)
.show();
}

【问题讨论】:

  • 所以你有一个将静态图像设置为背景的动态壁纸?

标签: android orientation landscape wallpaper


【解决方案1】:

我认为您只使用静态壁纸服务(不是动态壁纸)。这可以在不同的设备上以不同的方式工作。主要概念是它使用方形图像,其宽度与较长的屏幕纵横比。在大多数情况下,它会裁剪图像的中心,但根据我的经验,制造商可能会过度定义。这帮助我找到了更好的方法:https://github.com/kghost/android-static-live-wallpaper

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多