I've set up NetBeans to run my app on my Asus Transformet tablet, however, it runs using the size of a phone screen, and then gets stretched over the screen. How do I fix it so it uses the tablets resolution?
You can have custom layouts depending on the size of the screen. For example if you have a xlarge screen you can create the layout folder 'layout-xlarge' and 'layout-xlarge-land'. In these folders you can put the layouts (with the same name and variable names) but change the layout as needed.
I'd suggest reading this as well:
http://developer.android.com/guide/practices/screens_support.html
<uses-sdk android:minSdkVersion="4"
android:targetSdkVersion="11" />
Use targetSDK = 11 to target for the tablets. Your UI will automatically scale to the tablet size. Use minSdKVersion = 4, if your app should run on phones with Android 1.6 or more
For more API levels, you can check this out, http://developer.android.com/guide/appendix/api-levels.html
Related
My app has different layouts and styles for xlarge screens. This is important because on phones it is only used in portrait and on tablets it is only used in landscape.
A user contacted me a few days ago because since I published the update with the tablets layouts he can't see some of the objects in my main activity (prior to this update I only had portrait layouts - also on tablets). He uses a 7 inch tablet running Android 2.3.3 and for some odd reason it is using the layouts and styles from the xlarge directories even thew it should use the default layouts and styles.
I tested it on the emulator and had the same problem. I then changed only the android version to 3.1 (did not change width, height and density) and it worked as expected - the default layouts were used.
I don't want to use version qualifiers (layout-xlarge-v13) because then users with old android versions that have an xlarge screen will get the wrong layouts. For android 3.2 and up I could use sw720dp but older versions will not use this so problem remains.
I am able to tell at run time that the device is not large enough for the xlarge layouts but what can I do in that situation? Is there a way to make it use the default resources?
Android doesn't give its blessing to any 7-inch tablets running Gingerbread or below since Honeycomb was released. This means your device must be either old, or non-CTS compliant. You are looking at an extremely small pool of devices that are: API level 7-10 (roughly), 7-10 inches in size, that live outside the main Android ecosystem.
If you want to support such devices, I would recommend that you make layout-large-v7 and layout-large-v11. Assume that these nonstandard tablets will select the first one, and design for low- or medium-density 1024x600-pixel displays.
I have a backward compatible app which is using screen specific layout (only for HVGA). Structure of my layout is as follows:
res/layout
res/layout-480x320 (for HVGA)
layout-480x320 contains few sepcific XMLs.
Manifest is as follows:
<uses-sdk android:minSdkVersion="7"
android:targetSdkVersion="11"
android:maxSdkVersion="15"/>
When I am running this app in Galaxy Nexus (720x1280), the kayout is taken from 480x320 folder. I have built it on 2.1 target and 4.0 target. Both are resulting same result.
Can anyone please help.
This is a stange change made to ICS 4.0 (or may be 3.2).
Pre ICS:
If you specify "layout-480x320" it finds and exact match and take from this folder if you device is HVGA, else it will fallback to "layout" folder.
ICS:
If you specify "layout-480x320" Android think this layout is good for any resolution which is "same OR ABOVE" 480x320, hence it does not fall back to "layout" folder. So you have to provide another folder with higher resolution.
So, now it not EXACT match but a "Range" based matching.
I dont know if this is a feature or bug. But going through the documentation it seems, it is a feature. :)
My application which I built for 1.5, shows text blurry on high density screen of HTC Desire and the like. Here is a close up screen shot from my application (bad.png) and a better example (good.png)
alt text http://taypo.com/bad.png alt text http://taypo.com/good.png
Yes, I am building a soft keyboard. And the text is drawn with canvas.drawText. All the discussions I found online is about image resizing issues.
You should read this guide
Basically, if you want support 1.5 devices you should build your project
against SDK >= 1.6 with the minSdkVersion setted to 3:
<uses-sdk
android:minSdkVersion="3"
android:targetSdkVersion="4"
/>
On this way you will be able to have differents drawable resources for differents
screen size/density without breaking the compability with Android 1.5
which assumes all screens are "mdpi".
obviously you can't use any api released after sdk version 3
I'm getting ready to release my first application the marketplace. It's being written for devices running Android 1.5 and above, however there aren't any specific folders for the three different screen densities (I think those came around in 1.6). Should I make these folders myself? Where should I put image resources for the different densities and what should I put in my Manifest??
You will actually want to set your application up to target Android 1.6 in order to get the folders with different drawable levels, but then set the minSdkVersion="3" in the XML and rename the drawable-mdpi folder to just drawable. It will give you a warning about version mismatch but this is how supporting 1.5 but getting the nice features of 1.6 is done in Replica Island for example, which was made by a Google developer advocate. One thing to keep in mind is that by targeting 1.6 instead of 1.5, you can add targetSdkVersion="4", so that it will not force all screens to emulate 320 width, but then you will need to be far more aware of how the app will actually look and test it more thoroughly.
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />
For more information, read http://developer.android.com/guide/practices/screens_support.html, especially about halfway through where it mentions the XML settings.
There are a number of bugs in the system that need to be worked around as well.
The best strategy I've found to use is:
res
drawable
drawable-hdpi-v4
drawable-ldpi-v4
layout
layout-hdpi-v4
layout-ldpi-v4
we have a problem related to the manifest file and the property "android:minSdkVersion".
The issue is: If our platform is 2.0 and we use the property "android:minSdkVersion=3" (3 = sdk 1.5) the graphics get corrupted (In details, the application's resolution get reduced to a 2/3 part of the original size, this is, when the resolution should be 480x720, it becomes in a 320x480). This is happening on the Android emulator, and on the devices Droid/Milestone (Which are platforms 2.0). When we switch the property to "android:minSdkVersion=4" (4 = sdk 1.6) the problem gets solved, but when we want to put that version on platform 1.5, Android doesn't allow us to install it.
It would help us to know any conflict regarding graphics within the 2.0 sdk, or any known problem around the "android:minSdkVersion" in the manifest.
Thanks!
If you specify targetSdkVersion as well as minSdkVersion your application will start to work correctly on all platforms.
So have an entry in your manifest like this:
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
This is covered in the Android API Levels page in the Android Developer documentation.
I assume you're specifying different assets for different screen densities using directories like res/drawable-mdpi, res/drawable-hdpi and so on?
Android 1.6 (API level 4) was the first version of the SDK to support multiple screen densities, so it knows the significance of these directory names and so can successfully select the correct drawable from your res folders for the particular device it's running on.
However, if you run an application developed in this way on an Android 1.5 device (API level 3), then the framework does not know that it should only use the medium DPI resources (as there are no Android 1.5 devices released with anything other than medium DPI screens (AFAIK)). So in this case, the framework can end up choosing seemingly randomly from all the available resource in your APK, whether they're intended for high density screens or medium density screens, or whatever.
However, I haven't seen the reverse happening that you are, i.e. a 2.0 device appears to select drawables for, or assumes, a different screen density.
I would make sure your res directory layout is correct, and that you're using density-independent measurements in each of your layouts as appropriate.
But if you want to support multiple screen resolutions and densities and support Android 1.5 devices in a single APK, then I don't believe it's possible.
Add this tag in your AndroidManifest.xml to support multiple screen densities.
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="false" />