如何设置图像从ImageViev壁纸 [英] how to set image as wallpaper from the ImageViev
问题描述
我有在其中有两个按钮和一个ImageView的活性。一个按钮是把图像从手机的摄像头应用程序并将其设置为ImageView的,和其他按钮来设置图像作为主屏幕墙纸,所以我想在code如何从ImageView的设置此图片到墙纸???????
i have an activity in which there are two Buttons and an ImageView. one button is for to take image from the Camera application of the phone and set it to the ImageView, and other Button is to set that image as the Home screen wallpaper so i want the code how to set this image from the ImageView to the wallpaper???????
推荐答案
第1步:获取连接到ImageView的图像。
Step 1: Get the image attached to the ImageView.
SETP 2::设置该图像为墙纸
第三步:添加权限在的AndroidManifest.xml
来设置壁纸
Step 3: Add permission in the AndroidManifest.xml
to set wallpaper!
对于第1步检查这回答!
imageView.buildDrawingCache();
Bitmap bmap = imageView.getDrawingCache();
对于第2步:
For step 2:
WallpaperManager m=WallpaperManager.getInstance(this);
try {
m.setBitmap(bmap);
} catch (IOException e) {
e.printStackTrace();
}
有关第3步: 包括此权限了。
For step 3: Include this permission too.
<uses-permission android:name="android.permission.SET_WALLPAPER" />
告诉我,如果不适合你!
Tell me if that does not works for you!
这篇关于如何设置图像从ImageViev壁纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!