Android app wont scale to fit Tablet screen - android

Hi im having problems getting an app i have written for the motorola xoom to fill the screen. When i run the app it runs it in the middle of the screen as if it was on a phone or something. When creating the main.xml at the top it is showing the screen as a 10.1in WXGA screen and the system at the right hand side is set to Android 3.1
Any idea what im doing wrong?

Screen sizes beyond phone screens was added in Donut (API 4). Thus to say that you know about different screen sizes, you need to set at least API 4 as the target SDK version in your manifest:
<manifest ...>
<uses-sdk android:targetSdkVersion="4" />
  </manifest>
This allows the system to use the modern defaults for the supported screens that you can specify with this:
http://developer.android.com/guide/topics/manifest/supports-screens-element.html
The use of android:targetSdkVersion is very important, since it allows the platform to disable a variety of compatibility behavior for your app to allow it to run better on more recent versions of the platform. Some of the things it impacts can be found here:
http://developer.android.com/reference/android/os/Build.VERSION_CODES.html

I had the same problem with porting to Galaxy Tab. Make sure you specify the correct API Level. I used an old one and had the same behaviour.

Try adding this to your AndroidManifest.xml: <uses-sdk android:minSdkVersion="4" />

Related

Android Tablet Zoom option missing

I've developed an android application whose GUI is designed for small screens. When run on a tablet it looks rubbish because I've assumed 320dp width to make my life easier - I don't have the resources to test on tablets.
People using android 3.2 were able to zoom into the app so it looks like it's running on a big phone. But after my last update that option is not available, and I don't understand why.
The change is related to the Manifest file. Here's what my orignal app had (there's nothing to do with screens in my Manifest):
<uses-sdk android:minSdkVersion="7" />
After updating my development environment, I got a warning saying I should specify a target sdk, so I did this:
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="10" />
Using a painfully slow Android 3.2 emulator I have confirmed that this has caused the problem. I thought any target SDK below 11 wouldn't affect the zooming option?
Using the following also removed the zoom option:
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="9" />
But this didn't:
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="8" />
So setting my target SDK to 8 is a workaround, but it's also wrong because I use version 2.3.3 for testing.
Am I missing something here? Is there a better solution?
Thanks.
Try setting targetSdkVersion to 9 (or 10) and adding <supports-screens android:xlargeScreens="false" /> to your AndroidManifest.xml (docs for supports-screens). This tells the system that your application does not explicitly support xlarge screens and that it should offer the compatibility zoom/scale option for users that use the app on xlarge devices. Note that this will not cause the app to be hidden from xlarge devices on the Play Store (supports-screens only causes Play Store to filter apps from smaller screens if they are designed to run on larger screens, not the other way around).
The reason I think this is happening once you set targetSdkVersion to 9+ is because supports-screens xlargeScreens was added in API Level 9 and (I believe) defaults to true (for API Level 9+ at least). Once xlargeScreens is true the system will disable the compatibility zoom/scale mode.
Supporting docs (where it does say this but is fairly convoluted):
http://developer.android.com/guide/practices/screen-compat-mode.html
http://android-developers.blogspot.com/2011/07/new-mode-for-apps-on-large-screens.html
http://developer.android.com/guide/topics/manifest/supports-screens-element.html

Android: Layout appears truncated on real phone

All along I've been testing on an Android 2 version ported to x86 (which runs within VirtualBox), due to problems with the emulators. My application and layout appears fine on this port.
I am now finishing my development, and am testing on my real phone, a Droid Bionic.
However, my overall application layout does not take up the full size of my screen, even when I have my dimensions set to the below. There is a black outer box that it seems to reside within and I can't enlarge this window.
If I change the dimensions of my overall layout from fill_parent to say 1000px, I can see the layout being truncated as it still sits within this unchanged window size.
Can anyone advise me how to resolve this?
Thanks
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#layout/overall_background"
android:orientation="vertical"
>
<GridView
android:id="#+id/gridView"
android:gravity="fill_horizontal"
android:stretchMode="columnWidth"
android:horizontalSpacing="0px"
android:background="#layout/grid_background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
Edit:
I am fairly sure this is because of the screen compatibility mode you are running in because your android:targetSdkVersion in your manifest is set incorrectly. This should be set to the highest SDK version that you have tested your app with and it works on.'
Please see this link and in specific read the first few paragraphs.
There are two versions of screen compatibility mode with slightly
different behaviors: Version 1 (Android 1.6 - 3.1)
The system draws the application's UI in a "postage stamp" window.
That is, the system draws the application's layout the same as it
would on a normal size handset (emulating a 320dp x 480dp screen),
with a black border that fills the remaining area of the screen.
To disable this version of screen compatibility mode, you simply need
to set android:minSdkVersion or android:targetSdkVersion to "4" or
higher, or set android:resizeable to "true".
Edit: Please see the documentation on how you should be setting the target SDK attribute
These lines in particular are of interest:
To maintain your application along with each Android release, you
should increase the value of this attribute to match the latest API
level, then thoroughly test your application on the corresponding
platform version.
Given that your ran into this issue tells me your target sdk is set to 3 or lower. So Android 1.5 or lower. This means that anyone running your app on a phone with something newer then Android 1.5 is going to be running in compatibility mode. This leads to decreased performance and incompatible default graphics. I.E. the graphics will not look like what everything else on the phone looks like because of the compatibility mode.
Currently something like 95% of all Android are running a newer version then 1.5.
What you need to do is up your tarket SDK to 4,5,6,7 ... etc one at a time and fully test the App until you get to the current SDK release of 15. When you release the target SDK should be 15 to ensure it runs well on all OS versions.

Problems with layout using <uses-sdk android:minSdkVersion - Android

I was publishing my first APP but i have a problem, I have tested my app with a lot of AVD then i tested with my phone(Galaxy S) and with my girlfriend phone (Galaxy 5) before publishing, when i tried to publish i received a msg to specify an API level requirement. then i put this code
<uses-sdk android:minSdkVersion="4"
android:targetSdkVersion="7"
/>
then i tested in the AVD and i had no problem, but when i publish and tested in my Galaxy S, i encountered a crazy layout of my app, i do no why, so i go back to the Eclipse and tested direct to my galaxy S and get the same error, so i take this part of the code out and then tried again in my galaxy S and the layout is all OK, so i`m probably doing some thing wrong.
Many Thanks Sorry my poor English i`m from Brazil.
I think it is do with your layout defintion. What values have you used for layout_width and layout_height? (for layout and widgets)? You should use "wrap_content" of "fill_parent" and if you are forced to give exacts, give values in dip (100dip) rather than px or pix. Read this doco for more details http://developer.android.com/guide/practices/screens_support.html
It may be because your 2 phones have different android versions. Do this, create 2 emulators with exact same android version, screen size and density as your 2 phones and test and debug there.
Leave the minSDK declaration and get rid of the target SDK. You are using two separate declarations.
<uses-sdk android:minSdkVersion="4"/>
This is the only one you need.
I have seen this too. My app runs on everything from api level 4 and up. When I add
<uses-sdk android:minSdkVersion="4"/>
to my manifest and run on my G2 I get a crazy layout. Thanks for this heads-up. I will report later on the changes I had to make.
m.

Generating Balls for Android Game

I am making a game in Android where i am generating random number for different colored balls. Currently i am generating buttons dynamically and settings the background resource.
I am using some high resolution icons as images. However when they render on screen, all of them gets slightly pixelated and don't look good on screen. I tried it with different sizes of icons but it was of no use.
Can anyone suggest where i can be going wrong and what can be the best way to take care of these things. I am new to game programming so any help would be appreciated.
I would guess that your application is not running at your phone's maximum resolution. You need to specify the target version of Android in your manifest file, otherwise the app defaults to an early version and only runs at low-res.
If your phone supports Android 2.2 (Froyo) then try adding this line to your AndroidManifest.xml file:
<uses-sdk android:minSdkVersion="8" />
Be sure to put it in the manifest section, not the application section. If you see a line for "android:versionName" then put it immediately after that line.
If your phone doesn't support Android 2.2 then change the minSdkVersion number to 7. If it's an older version then go down to 6 or 5. You'll need to make sure you have the correct SDK files installed on your development machine. (ie: you won't be able to compile an Android 2.2 app if you only have the 2.1 SDK installed.)

Why is my app not showing up for 1.5 users in the Android Market?

The app is Flash Cards Max on the Android market. I recently updated my app with a 1.6 only feature. However, I still want the app to work with those that have Android 1.5. I built it using Android 1.6 in Eclipse and I have the correct strings in the Android manifest file.
<uses-sdk
android:minSdkVersion="3"
android:targetSdkVersion="4"
/>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Everything works in the emulator fine on 1.5 just want to be sure it shows up on the Android Market for those with 1.5. It does not. This is a market filtering question.
Please see this thread for info on what I changed and how I went about it thanks to several of your suggestions.
tl;dr
Why doesn't my app show up for 1.5 users?
Answer by a helpful user on Reddit.
"I had the same problem, solution was <supports-screens/>
Why?
Because
android:anyDensity
Indicates whether the application can accommodate any screen density. Older applications (pre API Level 4) are assumed unable to accomodate all densities and this is "false" by default. Applications using API Level 4 or higher are assumed able to and this is "true" by default. You can explicitly supply your abilities here."

Categories

Resources