Scale images according to device - android

I have developed an Android game using a Canvas. When I port the game on devices with different resolutions, the graphics, such as ImageButtons, get scaled according to resolution, but the background images do not scale appropriately.
I have written these lines in manifest file :
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"
/>
Why don't the background images scale correctly?

You can use ImageView.ScaleType
ImageView.ScaleType="CENTER_CROP"

Try to use an ImageView that will most likely scale automatically. At least it did in my program. It's worth a try.

Related

android image size with mdpi ldip hdpi xdpi

I have put 4 image for each folder mdpi,ldpi,hdpi,xdpi in the ratio of 3:4:6:8.
Now I need to make any changes in androidmanifieast.xml file or application automatic select from which folder he need to pick up proper image according to screen resolution of device?
Thank You.
Now I need to make any changes in androidmanifieast.xml
you have to add this code in manifest.xml file
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"/>
application automatically pick up proper image according to screen resolution..

Android application for Tablet

I have developed an application that is to be run on android Tablet as well. It is working on android phones perfectly. When I ran it on Tablet, it did not expand on whole screen. It just covered a area equal to a mobile device. I want that it also runs on Tablet and cover the whole screen as running on mobile device. Do I have to create two different designs for each type and at run time before using design, I would have to check it whether it is android phone or table?
Add below code in android manifest
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
Add the following block of code in your manifest file after the <uses-sdk>tag:
<supports-screens
android:xlargeScreens="true"
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
Note: Add the android:xlargeScreens="true" attribute if and only if your minSdkVersion is equal to or more than 9.
In addition to adding this block of code, follow this link. Also suggest you to go through the following links:
Supporting Multiple Screens
Supporting Different Screen Sizes
Supporting Different Densities
Hope this helps.
please try
<uses-sdk android:minSdkVersion="8" android:maxSdkVersion="11"/>
<supports-screens android:anyDensity="true" />
in Manifest.xml before tag.
I hope it may be help you.
Yes, ideally you'll design layouts targeted to tablets. You don't have to, but you can. See here for details. Your app is running in "screen compatibility mode". See here for info about that.
I think you used fixed width and height for any view or layout in your app, to support a fixed resolution of your mobile device.
If you use fill_parent, wrap_content and weight property, such things in your app, the app will fill entire screen of any android device. Once review your code.
Small example
Assume device has no rotation. Your device has resolution 320 X 240. you have to fill 3 buttons horizontally, you can put each button width=100 and remaining as margin/padding of layout. If you run same app on device with resolution 640 X 480, some space will come after 3 buttons. If you use width=fill_parent and layout_weight=1 for these 3 buttons and parent's layout_width=fill_parent, on any resolution these 3 buttons will fill the entire width of screen.
I hope it may help you.

How to create android's application supporting multiple screen size

I look over some guide and tutorial but my problem still exists.
I develop this application using small image to create button, text and background and i put it in res/drawable-ldpi directory. Then i see on web that i have to make images with this proportion:
3:4:6. So if my images were small, to create them for medium screen size, i have to take dimension of small image and multiple for 4/3, and for large screen multiple for 6/3=2.
I see these here: Providing Resource.
Now when i create just some images for normal screen ( medium ) i launch emulator with screen density 160 or 200, but the image still remain that used in ldpi.
What can i do?
Can you explain me well what is the problem with these multiple screen and how to solve this?
This is a part of my android manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="spazio.digitale.com" android:versionCode="1"
android:versionName="1.0" android:installLocation="auto"
android:screenOrientation="portrait"
>
<uses-sdk android:minSdkVersion="7" android:maxSdkVersion="11" />
<uses-permission android:name="android.permission.INTERNET" />
<supports-screens android:normalScreens="true"
android:smallScreens="true" android:largeScreens="true"
android:anyDensity="true" />
use to pixels scale to design..
put this in manifest
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"
/>
For button, create images using 9-patch tool.
With bitmaps, the rule of thumb is to start with the highest density first, and then scale it down, because it's always easier to scale down bitmaps than to scale them up.
Also, you seem to be confusing screen density with screen size. Do not worry about the screen size for now (unless you have one background image that takes the entire screen size, which I doubt). And no, the ratio you mentioned has nothing to do with screen sizes, that only applies to screen densities. Fix the density issue first and foremost. Then, once that's fixed, you can focus on making sure the layout fits the size.
And don't even bother with ldpi, that's only 0.2% of the market of handsets. You're just wasting your time optimizing for that density.

Image loses quality in WebView

I'm displaying a 1500x1000 px sized image in an Android WebView, but it displays it in poor quality. I read somewhere that quality can be preserved using and displaying many smaller parts from the original image, but that seems like too much work and not sure how it really could work.
I added
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true" />
and created a drawable-hdpi folder and put the image in there, with no change.
Has anyone done this succesfully or any suggestions?

Android Application not fit to screen correctly

I have found a problem in Android Emulator,
when i run application on Emulator on android 2.3.3 WQVGA400 it runs fine,
but screen width size is so small
so i check the Built in Resolution to make width size to 800" something and height t0 600"
Now my problem is when i run application on this, then it shows only in a short portion of Emulator screen, extra space on below is always remain
And one thing is that when I run on Actual device is runs very perfectly
You should probably read this: http://developer.android.com/guide/practices/screens_support.html
Add to your AndroidManifest.xml
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
How do you add the text in the green buttons? Is this button a nine patch image? Is the text separate from the image?
Use nine patch images. Then add the text using Button control, where you put the image as background and the text as caption/title/text so on. And when you run the application on larger screen, the image + text will be resized correctly.
Add next line to your AndroidManifest.xml:
<supports-screens android:resizeable="true" />
More information about this attribute can be found in documentation.

Categories

Resources