Android 中设置桌面背景
- Resources res=getResources();
- BitmapDrawable bmpDraw=(BitmapDrawable)res.getDrawable(R.drawable.icon);
- Bitmap bmp=bmpDraw.getBitmap();
- try{
- setWallpaper(bmp);
- }catch(IOException e) {
- e.printStackTrace();
- }
2.在manifest中增加设置桌面的权限
- <uses-permission android:name="android.permission.SET_WALLPAPER" />
处理:点击编辑框,图片被压缩的问题:
在主配置文件的<activity>中加入:
android:windowSoftInputMode="adjustPan"
代码:
- <activity android:windowSoftInputMode="adjustPan"/>