嗨,我以编程方式设置了主屏幕壁纸。它工作正常。如何根据模拟器大小调整主屏幕壁纸。我的示例代码在这里...
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Drawable drawable = getResources().getDrawable(R.drawable.sample);
Bitmap wallpaper = ((BitmapDrawable) drawable).getBitmap();
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int screenHeight = displaymetrics.heightPixels;
int screenWidth = displaymetrics.widthPixels;
Bitmap bmp2 = Bitmap.createScaledBitmap(wallpaper, screenWidth, screenHeight, true);
try
{
wallpaperManager.setBitmap(wallpaper);
}
catch (IOException e)
{
e.printStackTrace();
}
基于模拟器大小以适应主屏幕壁纸,如何?
请回复您的意见,结果对我很有价值。谢谢。