Java代码  
  1. Resources res=getResources();   
  2. BitmapDrawable bmpDraw=(BitmapDrawable)res.getDrawable(R.drawable.icon);   
  3. Bitmap bmp=bmpDraw.getBitmap();   
  4. try{   
  5. setWallpaper(bmp);   
  6. }catch(IOException e) {   
  7. e.printStackTrace();   
  8. }   


2.在manifest中增加设置桌面的权限 
Java代码  
  1. <uses-permission android:name="android.permission.SET_WALLPAPER" />  



处理:点击编辑框,图片被压缩的问题: 
在主配置文件的<activity>中加入: 
android:windowSoftInputMode="adjustPan"
 

代码: 
Java代码  
  1. <activity  android:windowSoftInputMode="adjustPan"/>  

相关文章:

  • 2021-12-26
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-19
  • 2021-05-20
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-24
  • 2021-09-14
  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案