I want to programmatically set a wallpaper to be an exact fit of the current screen.
Android fits the image to scroll as you change windows by defalt and so you never see the whole image on any one screen.
Applications like Wallpaper Wizardrii perform the function of setting the image to a single screen for the user, but I have never seen an answer on any forum that suggests how this is done.
Can any Android guru out there help - this problem has been doing my head in for nearly a week now!
You need to write a Live Wallpaper so you can render your image to the screen exactly how you want. If you just set a static image, the launcher app (or anything else showing the wallpaper) will be free to adjust it and resize and scroll. By writing a live wallpaper, you get to receive the requests from launcher about what it wants to happen to the wallpaper, and follow or ignore them as you want.
Also conceptually "make the wallpaper an exact fit for the current screen" is not even possible, because there is only one wallpaper, but two orientations (landscape and portrait) it can be shown in. That one wallpaper just fundamentally can't exactly fit both orientations.
Related
I'm using a Wallpaper Manager for setting an image as Home screen. It works fine for Lock Screen, but not for Home screen. This image that I want to set as Home screen is as wide and long as the screen, so it gets blurred when stretched across multiple screens. I'd like for this image to be repeated on each screen, not stretched across all. Is there any solution? I'm open to any idea, even if it doesn't include wallpaper manager.
I get it too, bro. But this package have a function called setWallpaperFromFileWithCrop
so you can let user crop image to set wallpaper as you want.
I have a JPEG photo which I want to use to as a background for one of the screens.
I want the behaviour to be simlar to the css backgroundSize: cover property. (Play with the following tool to see what I mean: https://davidwalsh.name/demo/background-size.html)
For iPhone, this issue is fairly easy, as you can literally have several different versions of the same image depending which iPhone the app is being installed on.
For Android, this is much more difficult as they have various different aspect ratios and resolutions.
Therefore my question is, how can I specify an image that covers the entire screen.
You can always fake this by adding the imageview inside a View and calculate the proper height/width you need to cover the screen (get the shortest side and scale it up and multiply the other side by the original ratio).
You could also use https://github.com/AndreaVitale/imageview that supports a cover mode
For Android, My suggestion is to use 9-patch Image instead of normal image. It will stretch it self to entire Screen, if you placed image as background
of Window it self as well as worked for ImageView perfectly.
Thank you.
I am newbi in android world and working on an android app.
I have used many of buttons and image buttons in my app.
Now i want to replace them with an background image. (So i can make nice gui easily)
I know i can use view listener and i can find the clicked x and y coordinate from onclick method.
But I want to how can i find which part of the image was clicked. Because different phones have different resolutions how can i do this efficiently ?
And one more thing, Is it good to handle gui this way ?
Thanks !
You first need to set the initial window width and height before execution of other code and load an image of quality based on the screen size. so for example you can have 3 sets of images of different size. One for 5 inch screens and below. Another for 7 inch tablets. Another for 10 and possibly another super high quality image for anything above. As many devices coming on in the near future are reaching resolutions much higher then previously developed for. Just run code initially that detects the initial window size at hand and load image based on resolution of that device. From their program as you plan to.
Also to jump on answer above. Detect rotation event and adjust image accordingly. and update accordingly. You are adding more programming of course but no reason what you are asking could not be done. Just a few extra events detection and you should be good to go to accomplish exactly what you are looking to do
AFAIK it is not good practice to handle the GUI this way. Mostly because android screen size is not standard and so you can never be sure that it will work perfectly in all the devices. You can ofcourse handle the events using onTouchListener and see which part of image was clicked from the coordinates in the MotionEvent Object. But, I would not recommend doing so.
Creating layouts of different screen sizes and handling the events using Buttons and ImageButtons will be good.
you can use android:background attribute for background images in the layout xml files...
however you also can set the background of UI element programatically
I've been facing a problem. How do I set a wallpaper in Android, without stretching it across 5 home screens. To be clear, I have a resource images with resolution 320x480px and when I set it as wallpaper in Android, it gets stretched across 5 screens, but I want it to show up only in 1 screen (or the same image in all screens), got it?
I'm not interested in using a livewallpaper.
Only way to have an app do that is using a live wallpaper.
There are two types of wallpaper, static and live. The scrolling of a static background is controlled by the launcher app. This is why LauncherPro and ADW can control the scrolling. When the user chooses a live wallpaper, the launcher simply displays whatever the LWP wants to render, so the LWP controls the scrolling, if any. This is how MultiPicture LWP solves the problem.
So your only options are to implement a custom launcher (which I doubt you want to do for such minor functionality) or implement a live wallpaper.
And BTW, setWallpaperOffsetSteps is an internal method called by the launcher on a live wallpaper, so the LWP knows where it's supposed to be drawing. You can't call it directly, but you can listen to onOffsetsChanged within your LWP to facilitate your own scrolling implementation.
Tap and hold your screen when you get popup "add to home screen"
select "wallpapers"
select "home screen wallpaper"
when you've selected a picture from gallery or explorer you get a screen where you can crop your Image to fit home screen.
On the bottom you can select 2 type of crops.
A big crop for setting it accros 5 screens and a small crop to use the same BG on all 5 screens.
see screenshot:
select the latter, crop your picture and save.
Not possible. May be there are any private libraries for it.
Apparently it's not native Android functionality. You can, however, get apps that do it. "Launcher Pro" and "ADW EX Launcher" can both disable scrolling but you may need to create a landscape rectangular image with empty borders at the right size.
Alternatively, the app "MultiPicture Live Wallpaper" may do what you need. A reviewer wrote: "Lets me use a picture sized the same as my phone's screen as the background on all pages of the launcher. Not sure why that isn't part of Android."
EDIT: have a look at tdtje's post before you try these. If that works, then awesome. I'm not sure which version of Android that became available in, as I'm using 2.1 without that feature.
FURTHER EDIT: In the comments below, Martyn gives us a first hand opinion!
I went to Settings and clicked on home screen. Then went to wallpaper. I selected my picture and cropped using the gallary app. This had a setting on the top to either stretch or not. I'm running Android 4.4.
I'm entirely new to Android development, and I'm interested in making a live wallpaper. I was thinking about looping a set of pictures instead of drawing the animation. Is this a possible approach? If possible is this a suitable or ideal way of doing it, does it eat up memory and would i need images with different resolutions because of the fragmentation?(hundreds of different devices)
Thanks in advance :)
Sure, it should be fairly simple.
The main part of the Wallpaper engine is the Drawing of course. You need to handle the drawing manually, there is no easy way to loop through images... you need to code it. You will have to continuously monitor the time which has passed and adjust the displayed image based on that. You are given a Canvas object to draw to and it is all done during run-time in code.
The Wallpaper engine class has a event called onSurfaceChanged which gives you the width and height of the Surface which you will be drawing to. It will be called everytime the screen dimensions change (like if the phone is put into Landscape mode for instance). You need to have code that will handle any combination of width or height for all the device types out there. You will need to decide if you are going to stretch, center, tile or crop (Or a combination of those) the source images to fit any particular screen size. I would recommend scale to fit so that the image is either taller or wider than the screen and center the image either vertically or horizontally (cropping the extra bits) once that is done. I personally just use one source size and resize it to fit. You can opt to use several source files if you want which is the recommended approach I believe, but it's a little confusing.
I would start by creating a Live Wallpaper which just draws something basic like a shape to the screen. Then work out how to display an custom image and take it from there.
Good luck
You will need to be very careful about memory if taking a frame approach to animation--probably will not be possible to animate full frames--much more practical to move sprites on a background. See, fr'instance: http://davidjhinson.wordpress.com/2010/05/19/scarce-commodities-google-android-memory-and-bitmaps/
what if you have a png frame animation that is set at a certain x and y position that sits in a spot on the background image, both would have to be rescaled