My screen size is 600px * 800px.
I created some wallpapers whose sizes are 600px * 800px or width:height=3:4,
when they were set as wallpaper, they got stretched, so the lower and right part couldn't be seen.
Does anybody how to solve this problem to make my wallpapers fit to the screen?
Android crops a part of your wallpaper so that when you swipe left and right, the background scrolls with it. For more information see this link or this link
Related
I want to show a fixed 640x640px image on the screen and below that image 2 images that are fixed sized for 128x128px.
In graphical layout, the default(?) width is 320px and height is around 460px so I can't do what I want. I know I should support different screen sizes but for now I want to work with my minimum requirements and then change things according to the screen sizes. How can I "force" the graphical layout to be 640x640 or other standard size which is around that size?
Thanks
640*640 is no standard size (no device, as far as I know has a square aspect ratio).
You can emulate a device with a bigger screen size, such as 1280dp by 800dp (WXGA).
By the way, you can't "force" a layout to be bigger than the screen size.
I've built an AS3 game with a stage size of 480 by 800, but I still get small margins on the top and bottom. I haven't made any coding relating to screen size cause I understand that 480x800 is the screen size that should fit exactly to the samsung 3 and 4 screen. I don't need it to fit other screens at the moment nor do I need it to orient (just portrait).
I read that the screen ratio is 9:16 so I tried with a stage of 422x750 but I still got margins!
How do I get rid of these margins? Is there a stage size that would fit the screen without coding or do I have to put some code for that?
Check out stage.fullScreenWidth and stage.fullScreenHeight. These 2 properties work alright for me both on Android and iOS (unlike stage.stageWidth and stage.stageHeight).
When implementing a splash image which has such a design that image cannot be skewed or cropped if the device screen is of different resolution or size, how to perfectly implement this? Image must be a real full-screen without black background due to different aspect ration.
Shall we create splash image for every device screen size? This is how we do at the moment and it's pretty much work. So we go to Android developer support screen advise page to know what images sizes we need. you see, there are a lot of them.
Is there a better and quicker solution?
just get the splash screen in 1920*1080 and put in xxhdpi android system will auto ajust it
Stretch occurs when when try to fit an image into an image view of different Aspect-Ratio.
Create 2 or 3 images for major Aspect-Ratio and then use android:scaleType="fitXY" on your image view, for devices that uses different aspect-ratio than you specify it won't differ a lot so you don't get a noticeable stretch.
Most common aspect-ratio are:
2:1 // ultra wide ex. 800*400 screen
16:9 // HD wide ex. 1920*1080 , 1208*720 , 720*450
16:10 // wide
4:3 // old tv square-like
If you can prepare a image resolution 1920*1280 and put in drawable-xxhdpi, it would fit to any screen
Try to create a 9-patch image and use it as a background of the splash activity/view/whatever. Put your fixed size logo (or whatever you want to display) in the non-scalable part of the 9-patch and let the other areas stretch to fill the view. Note that the non-scalable area (e.g. your logo) should have size that will fit the smallest display you want to support.
in my app I have a preview screen. On one device (LG, with Android 2.2, 320x480 screen) and another one (HTC, with Android 2.3, 480x800 screen) everything is OK. In both cases the list of supported preview sizes include one that fits the screen size exactly, I choose it and the image is perfect.
The problem comes with yet another device, having a screen similar to the first one (Samsung, Android 2.3, 320x480 screen). Regardless of the fact that I select a preview size that fits the screen size, as in previous cases, the image doe not preserve its aspect ratio; circles appear oval; the image is squeezed along the short axis of the screen. It seems the hardware itself, in order to obtain a 320x480 preview, squeezes the image (the camera has a form factor 4:3, while the screen has a form factor 3:2).
So I have altered the layout params of the view where the preview appears, in order to fit the form factor of the camera (size: 360x480. This PARTIALLY solves the problem; actually, to solve it completely I had to set 380x480 (!!!).
The fact is that I can't possibly find any API that tells me about this different behavior, so that I can automatically compensate for it. Not even the Camera.Parameters.getHorizontalViewAngle and Camera.Parameters.getHorizontalViewAngle seem to be helpful; they give the same values on all of the three devices!
Can anyone help me?
After deeper investigation, that included writing ad-hoc code to check how the preview is actually shown on the screen, this is what I found out.
On one device (LG E-720), the preview image is cropped in order to obtain a 3:2 form factor, then it is resized to fit on the screen. Aspect ratio is preserved:
On the second device (Samsung ACE), the preview image appears to be cropped in a different way, resulting in a 5:4 image (!?), that is then resized to fit on screen. Due to the different form factors, the image on screen appears squeezed.:
I have checked whether a software update was available for the second device, but this wansn't the case. So in order to get a more or less correct image on screen, I have defined the target view as being 384 pixels tall; this actually causes a cropping that restores the correct aspect ratio. It doesn't compensate, though, a small horizontal shift due to the fact that the original cropping is horizontally asymmetric.
I'm creating a splash screen that will display while my Android application loads. I'd like to create it at the correct size so Android won't auto-scale it up or down to fit the screen. (It's a bitmap image, a photograph of an oil painting, so I can't just turn it into a nine-patch.)
But there are at least three important screen sizes I care about: 320x480, 480x854 (Droid), and 480x800 (Nexus One).
I've read the documentation on supporting multiple screen sizes, but I still don't see how I'm supposed to configure different splash screens for Droid/Nexus one (they're both "hdpi" resources as far as Android is concerned), and I don't know exactly how large my splash screen should be in any case. (How tall is the OS title bar/menu in Droid? N1?)
What size should I make these images, and how do I tell Android to use the correct size on a given screen?
You don't need to worry about the absolute screen size or status bars or anything — that's why we have nine-patch images.
What I did was have an image that looked good for each resolution — essentially a logo on a transparent background, with some text at the bottom.
Then I chopped off quite a lot of space at the top and side edges, made a nine-patch border round the image, with a single pixel near the left, right and top edges. This allows the image to expand evenly at the sides and top to fill the screen.
Edit, in response to Dan's comment below:
Yes, there is a way to determine which graphics should be used for which explicit screen sizes, but it's deprecated.
Just as there are drawable-hdpi and -ldpi resource qualifiers, it's also possible to use drawable-HHHxWWW — the larger pixel dimension coming first.
e.g. drawable-800x480 and drawable-854x480
Okay, firstly: you can find the device model via android.os.Build and use that to determine which image to show.
Secondly, I personally wouldn't bother. Layouts should be done in dip since every android screen is 320x480 dip I believe, and android maintains aspect ratio among devices very well through this in my experience. A 480x800 splash set to fill parent has been pretty reliable on both N1 and the droid as far as I have encountered.
Another solution that I implemented is to put an ImageView that fills the screen (width and height both "MATCH_PARENT") with scale type "centerCrop". This way, the image is not stretched but cropped along the edges. Try not to put important content (logos and stuff like that) close to the edges. If it is a photograph, I hope that the edges are "expendable" and can be cropped out.