Cri*_*iss 9 java android background gallery slideshow
我有一个应用程序,如幻灯片放映或画廊,但我想当任何人使用此应用程序能够将图像设置为Android手机上的背景
该应用程序可以显示图像我只想将图像设置为背景 - 如果我可以设置变量中的图像的地址,它就足够了然后我可以使用此代码
WallpaperManager wpm = WallpaperManager.getInstance(getApplicationContext());
try {
wpm.setResource(R.drawable.image_1);
} catch (IOException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
这是一个简单的教程。访问此链接如果您有 imagePath,则使用以下代码:-
is = new FileInputStream(new File(imagePath));
bis = new BufferedInputStream(is);
Bitmap bitmap = BitmapFactory.decodeStream(bis);
Bitmap useThisBitmap = Bitmap.createScaledBitmap(
bitmap, parent.getWidth(), parent.getHeight(), true);
bitmap.recycle();
if(imagePath!=null){
wallpaperManager = WallpaperManager.getInstance(this);
wallpaperDrawable = wallpaperManager.getDrawable();
wallpaperManager.setBitmap(useThisBitmap);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
821 次 |
| 最近记录: |