Right now, i am developing Android Application using SDK 1.5 and testing application on HTC Hero, its firmware is Android 1.5.
Let me come to actual point: in application, i am having an imageview for displaying image (Image resolution is 320*480), now imageview is displaying image in full-screen perfectly, but when i am trying to test it on HTC EVO 4G (having resolution 480*800), image gets stretch.
So, what i like to do is want to display 320*480 resolution image in all screen-resolution mobile ? i means to say,if the mobile is of higher resolution(i.e. 480*800 , 480*854, or else) than the image should be displayed in "Center" portion of the screen.
So displaying image in Center in all screen (without stretching or cutting) resolution other than 320*480, what attributes i have to set ?
Simply set the scaleType attribute of your ImageView. Possible values here: ImageView.ScaleType You might want to use CENTER.
In addition you face another problem: You have to provide a hdpi image in addition to your mdpi image so your mdpi image does not get automatically scaled up to hdpi by the Android system, read more here: http://developer.android.com/guide/topics/resources/providing-resources.html
Edit: Oh, and I nearly forgot: The 'drawable-mdpi' and 'drawable-hdpi' folders are only possible if you build your project against at least Android 1.6. So you have to set your minSdkVersion to 3 and your targetSdkVersion to 4, and place your images into the normal 'drawable' folder in order for Android 1.5 to catch up. See this video from the Google I/O 2010 to learn more: Casting a wide net for all Android devices.
Related
I am using Android Studio. I am trying to set a screenshot from my device, as a background image for my activity -
android:background="#drawable/active"
I have my image inside the directory- res> drawable-ldpi> active.jpeg , Which Is the lowest density folder available I am aware of. The problem is, The background looks PERFECTLY crisp and sharp in the screenshot, but when I set it as my activity's background, it blurs.
How do I fix this? I have tried moving the image to the highest density folder drawable-XXXhdpi, but it becomes worse. I have even tried the drawable folder.
All depends on your phone density. You should make few version of your image for each pixel density (but remember that even mdpi is growing older). If you properly resize image for each density your phone should take needed size of background.
I have been struggling with this problem about a week and can not figure out how to make it work. I have some views on a screen. And one values\dimens.xml(sw320dp-xxhdpi) resource file. Also I have nexus 5.2 1080*1920 420dpi and nexus 5.0 1080*1920 xxhdpi. The layout appears differently on both screens. How to make it display the same on each device?
What resource file should I add (if it is any)?
How to add for example values\dimens.xml(1080*1920 420dpi)?
I think your layout is simply built as poorly scaling. Unless you have some very specific use case, you need to make sure your layout fills the area it is provided with regardless.
As for the resource folder, if you want to make sure the same layout file is used on large screens, it is enough to put it in the folder layout-sw360dp. If you have xxhdpi devices with the resolution 1080x1920, Android will select the same file for both since the smallest side will be exactly 1080 / 3 = 360 density-independent pixels.
How to make it display the same on each device?
In general it's impossible for all Android devices. I think best solution - using VectorDrawable or SVG format and scale vectors for each device.
I'm making a game on Android in Eclipse, and when I run it through the emulator, it appears fine. The emulator I set up has the resolution at 800x480 (sideways). When I run the game on my phone, with resolution 1920x1200, it screws up the bitmaps by only drawing a fourth of them. I've made test code and two screenshots to show what I mean.
Small screen, emulator, running 2.3.3
http://i.stack.imgur.com/2WstK.png
Large screen, Galaxy S4, running 4.2.2
http://i.stack.imgur.com/8wtAD.png
It's the same code on each. The top has the dimensions correctly in the emulator (frame size of the bear, which is 64x64), but on the larger resolution it's halved the width and doubled the height for some reason.
The bear at the bottom is set to be near the bottom coordinates whatever the screen size, which is why it's different in each screenshot. The rectangles and top bear is set from the top coordinates.
I can post code but I'm just wondering if it's some type of setting that I'm unaware of because of the difference in resolution.
One more thing, I have the rectangles flipped horizontally from their original bitmap, so the fact that it appears to have taken the top right part of the bitmap to draw is not part of this, as far as I know. Again, just wondering if it's some setting that auto-scales things if the resolution is huge. I have a feeling it's something like that, OR that it's running on such a newer version of Android. Could be lots of things I guess.
Android usually scales up / scales down the image if it cannot find the right image assets for the device resolution. I believe this could be the reason for the behaviour you are observing. You can read more about providing the proper assets for different device configurations here,
http://developer.android.com/guide/practices/screens_support.html
Alternatively, if you don't want android to scale your images you can also place the image resources under drawable-nodpi folder.
I am new to android development and now i have started developing wallpaper apps.I saw the android developer page which tells the ratio 3:4:6 or something which i don't understand. Everything is working but the image which i set go off the screen sometimes it gets cropped around the corners and image does not look good. i use the screen size 600*480 in hdpi. Any suggestion about the different size images i should use may be for ldpi,mdpi,hdpi, xhdpi.I want my wallpaper look good in home screens of both tablets and for large size screen mobiles.
Thank You.
3:4:6:8 , so if you have 600*480 in hdpi then it should go like this
3k:300*240
4k:400*320
6k:600*480
8k:800*640
but since there are multiple device with same dp but different screen size, you can never quitly fit for every device
Which are the default dimension of the Home wallpaper/background for the various Android screen configurations (small, normal and large screens with low, medium and high density)?
Are 9-patch PNG files supported for the wallpaper? Should I be using these instead?
I found a method in API level 5 that gives you the minimum size of the wallpaper, but I would like to support previous versions of Android as well.
Thanks!
A wallpaper is twice as wide as the device held in portrait mode. So 960x800 on a Nexus One, 960x854 on a Droid, 640x480 on a G1/Magic/Hero, etc.
This article on the Android Developers' site shows the range of screen resolutions for each density.
I believe the wallpapers have to match the screen resolution and are not stretched. You can see this if, for example, you create a new emulator with a high screen density like 480x854. The default home screen background is centred, with large black bands at the top and bottom.
The WallpaperManager API indicates that you must use a PNG- or JPEG-format image, even if you use the setResource() method — the resource must be a Bitmap and so not a nine-patch or other type of Drawable.
Don't guess, ask the WallpaperManager:
manager = WallpaperManager.getInstance(this);
width = manager.getDesiredMinimumWidth();
height = manager.getDesiredMinimumHeight();