Android: Layout appears truncated on real phone - android

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.

Related

How to change text size on Android Things?

I developed an application on AT_v0.3 developer version, Raspberry PI 3. The application on AT_v1.0 stable version size of text and other items are bigger and they are not visible.
Also, there is no option for sizes in the settings menu on AT_v1.0. So, is there a way to fix it without re-design the layouts?
There are many changes that may have to be made to your applications between the third developer preview and the stable version. In addition to APIs, you may need to update your layouts.
In a TextView, if the font size is too large or small, you can modify the XML contents to specify a specific font size:
<TextView
android:id="#+id/text_view_id"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="14sp"
android:text="#string/hello" />
You can also use a custom theme in order to modify a number of Textview elements to adjust them all to the same extent.
Quite an assumption, however...
The key difference between Android Things Dev Preview 3 (a.k.a 0.3) and the "stable" Android Things 1.0 is that for the 1st you set up you display resolution manually via config.txt compared to the "stable" version where the system is configured via Android Things Console. You can treat the console as a black box which may downgrade a display density for the sake of more wide display coverage.
it would be sad if an Android Things developer had to "re-designing the layouts" in order to fit the configuration coming from the console.

Designing android app for multiple screen sizes

I'm designing an android app with a minimum SDK version of 8. I have currently been testing it on a emulator running an about 4 inch phone...
I recently got a Nexus 7 and ran it on that. I thought it would just enlarge the screen (button and text including) so it was basically magnified... it wasn't
I thoroughly googled it and came up with using different layout sizes (I am using Eclipse by the way) so I made a 'layout-large' folder but I got the following error and no design view of the screen layout would show
'It looks like you are using a render target where the layout library does not support the tvdpi density.
Please try either updating to the latest available version (using the SDK manager), or if no updated version is available for this specific version of Android, try using a more recent render target version.
Exception raised during rendering: Index: 2, Size: 2
Exception details are logged in Window > Show View > Error Log'
How can I solve this? I don't want to change the minimum SDK from 8
The tvdpi seems to have been implemented in Android 3.2 (meaning SDK level 13). If you want to target the Nexus 7 displays, with alternate resources, I suggest targeting large screens instead of tvdpi. You shouldn't have to change your minimum requirement of SDK level 8 as it doesn't make sense to target TV densities when aiming for Nexus 7, but maybe that's just me.
There is another similar question here on Stackoverflow with a great answer: How to create different layout for Galaxy S3 and Nexus 7?
Also visit the Android developers design guidelines and specifically Designing for Multiple Screens for more information. The Android guidlines is a very good website that I use consistently.
First thing first, there is great information at developer.android.com about programming for different screen sizes. Fragments are great for this. Did you get rid of the 'layout' folder. It sounds from your question you just renamed the layout folder. I would start by reading at a lot at the Android developer information center. Check the first link.

Screen display problem in Gingerbread

I have upgraded my Motorola Atrix to Gingerbread (2.3.4), so far with no issues. When I go for my old apps and games which I developed previously, those are not displayed fully in the screen, it is only giving a 320x480-pixel display. Do I need to change my code or my phone settings?
Given that you currently use android:minSdkVersion="1", try setting minSdkVersion="4" or setting anyDensity to true.
Both should have the same effect of allowing your app to scale beyond Android 1.0 screen sizes of 240x320; before SDK 4 (Android 1.6 ) the default was not to scale as there was only a single resolution.

android: UI on real device problem

I wrote simple aplication for android. It works great in emulator. But when I installed it on real device (htc wildfire) then the interface became ugly. Except that it works good. TextViews look fine but the buttons, sprinners and list items look bad. Button corners seem wretched. All the lists (list view and list preference have no delimeter(line) between rows! When I scroll a bit the delimeter appears). Why?
The buttons probably become stretched because you're not using 9 patch images. Here's a good tutorial on 9 patch images http://developer.android.com/guide/developing/tools/draw9patch.html
Regarding the list view, you might want to set this field inside listview in your xml file
android:cacheColorHint="#00000000". That might do the trick.
Have you specified a targetSdkVersion in the uses-sdk tag in your manifest? If you haven't, Android will assume your app does not know about newer platform versions with different screen sizes/densities and run your app with compatibility scaling.
You should always set targetSdkVersion to the newest version of Android that you are targeting. This helps let Android know what compatibility behaviors to use for your app if things changed in newer versions. targetSdkVersion can be greater than minSdkVersion, meaning your app knows how to take newer platform features into account while remaining compatible with a minimum version.
Most likely, screen density is different on the device. Instead of specifying sizes in pixels (px), use sp for font size and dp for everything else. This way they will scale properly.

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.)

Categories

Resources