我想将我的应用程序的背景设置为与主屏幕的墙纸相同。如何在activity.xml中获取主屏幕墙纸?我能做到吗?

最佳答案

使用

final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
final Drawable wallpaperDrawable = wallpaperManager.getDrawable();

以获取当前墙纸。然后将其设置为您自己的应用程序的背景:
LinearLayout ll = (LinearLayout) findViewById(R.id.myLinearLayout);//Substitute with your layout
ll.setBackground(wallpaperDrawable);

如果希望将其作为初始背景,则所有这些都应该在oncreate()中发生。

07-24 09:47
查看更多