Android has the ability to set desktop wallpaper. The user types a “menu” and then selects “wallpaper” to set the wallpaper from the system. The resulting image of the wallpaper is correctly scaled both in portrait and landscape modes.
I made a small application that allows you to change the desktop wallpaper. It works fine, but I can’t understand what the secret is for the image to be the right size after it has been set as wallpaper.
I did this with png images that were 1280x1084, and also tried the same thing with 320x240 images, and they all appear the same size when the desktop wallpaper is set.
I searched for tutorials and examples of how to set wallpapers, how they are, but could not learn how to do it. Can you show me a sample code showing me the secret of this so that the resulting wallpaper is properly scaled?
I am sure that some WallpaperManager parameter should be used, but I do not know which one to use.
Thanks in advance.
Here is the code I use to set the wallpaper:
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); WallpaperManager myWallpaperManager = WallpaperManager .getInstance(getApplicationContext()); try { myWallpaperManager.setResource(R.drawable.kabanight1); } catch (IOException e) {
Indeed, Imad
source share