In Android Application Development, if the background of the system desktop is used as the background of the application, you must set the background of the application to transparent background, and set the window attribute to flag_show_wallpaper to display the background.
Modify the activity attribute in the androidmanifest. xml file:
<Activity Android: Name = ". wallpapertest"
Android: Label = "@ string/app_name"
Android: theme = "@ Android: style/theme. translucent">
Then, add a window attribute in oncreate.
Getwindow (). addflags (windowmanager. layoutparams. flag_show_wallpaper );
When dragging the background, we mainly use the two methods of the wallpapermanager class.
Public void setwallpaperoffsetsteps
(Float xstep, float ystep) since:
API level 7
For applications that use multiple virtual screens showing a wallpaper, specify the step size between virtual screens. for example, if the launcher has 3 Virtual screens, it wocould specify an xstep of 0.5, since the x offset for those screens are 0.0, 0.5
& 1.0
Parameters
Xstep |
The x offset Delta from one screen to the next one |
Ystep |
The y offset Delta from one screen to the next one |
Public void setwallpaperoffsets
(Ibinder windowtoken, float xoffset, float yoffset) since:
API Level 5
Set the position of the current wallpaper within any larger space, when that wallpaper is visible behind the given window. the X and Y offsets are floating point numbers ranging from 0 to 1, representing where the wallpaper shoshould be positioned within
Screen space. These only make sense when the wallpaper is larger than the screen.
Parameters
Windowtoken |
The window who these offsets shoshould be associated with, as returned View.getWindowToken() . |
Xoffset |
The offset along the X dimension, from 0 to 1. |
Yoffset |
The offset along the y dimension, from 0 to 1. Http://blog.csdn.net/yao_guet/article/details/6572739 |