我得到的当前壁纸如下:
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Drawable wallpaperDrawable = wallpaperManager.getDrawable();
现在是我当前的壁纸 (1152 X 1536)
我尝试将其作为 Activity 背景,但宽度与屏幕宽度不同。
ImageView rv = (ImageView) findViewById(R.id.main);
rv.setBackgroundDrawable(wallpaperDrawable);
我该怎么做?
请帮助我。
提前致谢
最佳答案
您是否将 RelativeLayout 大小设置为 match_parent? 然后,您可以通过编程方式将图像设置为适合宽边:
int width = getWindowManager().getDefaultDisplay().getWidth(); //get window width
yourIMG.getLayoutParams().width = width; // set Image width = window width
关于java - 将大图像设置为背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26571042/