i will be targeting my app to all the android devices, what is the best way of doing it? so far i will be targeting Android phone and Kindle-fire and here is my thoughts.
android phone and its working as expected with images,font size etc... so i thought to test my app for kindle-fire:
create AVD emulator for kindle-fire with the below specification but i have few problems testing on the kindle-fire:
the images are stretched out (not sure if the images size should be increased for kindle-fire?)
font size is smaller then android phone (which i have tested)
i have no back button in my activity so i assume the user will be able to use the back arrow button in kindle-fire but in the emulator there is none showing.
Here are the specs of the Kindle Fire
Width: 600px
Height: 1024px
Abstracted LCD Density: 169
Target: Android 2.3.3 - API Level 10
RAM: 512 MB
what do i need to do in order to look and feel on both android phone and amazon kindle-fire?
should i create two separate projects and target font-size and image-size?
i am not sure what else i need to consider.
For the font, be sure to use the sp unit of measurement.
For the images, you can store them in different folders and name the folder using different attributes.
http://developer.android.com/guide/topics/resources/providing-resources.html
I will say though, I had a difficult time differentiating between the kindle and my 10 inch tablets, because they are both judged to be large by android. So I just created different layout for them and checked for screen size in the onCreate. Here is the code.
Display display = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
if(display.getWidth() <= 600 || display.getHeight() <= 600)
{
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
setContentView(R.layout.kindle_fire_layout);
}
else
{
setContentView(R.layout.anything_else);
}
To test on the emulator, use the code bellow to avoid android recognizing it as a xlarge device. Then you can put your resources where they should be.
Also keep in mind the the kindle fire ui takes some pixels off the view for the bar, etc, so you might want to also consider that
final Configuration config = new Configuration(context.getResources().getConfiguration());
config.screenLayout = (config.screenLayout & Configuration.SCREENLAYOUT_LONG_MASK) + Configuration.SCREENLAYOUT_SIZE_LARGE;
context.getResources().updateConfiguration(context.getResources().getConfiguration(), context.getResources().getDisplayMetrics());
Related
I am trying to emulate a Huawei Y530. According to this site, it has the following specifications:
Screen: 480 x 854 pixels, 4.5 inches (~218 ppi pixel density)
This is what my WEB APP looks like on the actual device:
And this is what it looks like on a emulator, with the following specification:
Target: Android 4.3 - API Level 18
Device: 4" WVGA (Nexus S) (480x800 hdpi)
I know there is a difference in the height of the two devices, but still I believe that the emulator should show something similar to what the actual device is showing.
I tried to find the innerWidth and innerHeight of the real device with the following code:
var viewportwidth;
var viewportheight;
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined')
{
viewportwidth = window.innerWidth,
viewportheight = window.innerHeight
}
alert (viewportwidth);
alert(viewportheight);
The result is width: 320px and height: 544px
The innerWidth on the emualtor is: 480px and the innerHeight: 756px
Since the real device had a width of 320px, i tried using an emulator with the following specs:
Screen: 3.2" QVGA (ADP2) (320 x 480 mdpi)
With the following result:
You can always create a new emulator if the app will be developed only for this particular phone. The image attached emulates the exact properties of the Huawei Ascend Y530 phone.
Alternatively, if the app is being developed for different phone having different screen sizes, I would take a look at the xml file for the layout. Take note of the following attributes, like placing form widgets in relation to other widgets. For example: android:layout_toRightOf="#+id/ukFlag" for the Danish flag. There are actually several layout parameters you can paly around with until you get the right layout:
Layout_toLeftOf
Layout_toRightOf
Layout_above
Layout_below
You can also setup the positioning of the widget, to be either left_based, right_based or centred.
Hope this would help you better: Android Layouts
Without knowing too much in how you have done your application, it seems you are using fixed units like pixels to specify size. As this project is a web app, maybe you should consider to use what is called a Responsive Design approach. In that way your content can adjust to whatever size the screen is.
I'll let you a couple of useful articles to learn more about this:
Responsive Web Design in Wikipedia
Responsive Design Presentation
Responsive Design Examples
My BlackBerry Q5 can run Android applications and I'd like to optimize one of my existing apps for its screen. The resolution is 720x720, but the runtime also inserts a bar in the bottom of the screen, so usable resolution for Android app is 720x620 pixels, so I guess that's what the phone reports to Android app as the resolution.
Is there a way to make a layout that will apply only to 720x620px screens? The documentation for supporting multiple screen sizes says that there are w<N>dp and h<N>dp qualifiers, but they use scaled dp units and also means minimum available width in dp units, so they would not be useful in here.
I needed to solve your problem too, this is my solution.
The Q5 and Q10 screen density is xhdpi (scale factor of 2.0) so max screen size is 720x720px / 2.0 = 360x360dpi
Quoting from the documentation, Table 2, "Available height" row:
Specifies a minimum available screen height, in "dp" units at which
the resource should be used
[...]
When your application provides multiple resource directories with
different values for this configuration, the system uses the one
closest to (without exceeding) the device's current screen height.
[...]
Added in API level 13.
Based on these, for Androids with API>=13 (including Blackberrys) you can put your Blackberry specific layout in "layout-h240dp" folder and all the others in "layout-h361dp"
Blackberry height is greater than 240dp and less than 361dp, so it will use layouts in h240dp folder.
Notes:
- If you don't add the 361dp folder, the 240dp folder will be used for every device with height greater than 240dp.
- I choose 240dp because it is a common minimium dimension for today devices.
- 309dp should work too as it less than 310dp (minimum height of BB's screen with bars)
- For Androids with API<13 you have to put a default layout in the generic "layout" folder, because the previous "h*dp" folders are ignored. if default layout is missing, the app should crash.
I don't mean to turn this into a full-blown answer, but I need the extra space.
For your assets, if you'd like to target them specifically for Q5 or Q10 devices, place them in the drawable-square folder. This changed from drawable-small-square due to deprecation.
If you plan on deploying to OS 10.2.1+ devices and don't want that back-bar to show by default, you can add a small configuration file to your app so that the system knows not to show it.
For more information on that, take a look at my blog:
Android Developers: Eliminate the Back-Bar in Your 10.2.1. App
I've developed an application designed for 4 inches devices (min SDK 8 - Android 2.3.3).
Now I need to support also tablets (7 inches or 10 inches).
The app (as it is) on tablets covers a bit more than half screen.
This is not acceptable for users.
I would like to move all objects (TextView, Buttons, ImageView) in order to occupy the whole screen.
Because the min SDK is 8 (Android 2.3.3) I cannot use Fragment, I'm right?
I've tried using screen percentage without substantial results (I'm a newbie!!!).
Thanks in advance.
If you want your app to run on tablets too. you have to make layouts for Tablet in a separate folder under res e.g.
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
also use hdpi/x-hdpi images in drawable as well
see guidelines given by android
http://developer.android.com/guide/practices/tablets-and-handsets.html
and also here
http://developer.android.com/guide/practices/screens_support.html
I need a lot of Android tablets for resale with my app. I bought some from internet (cheap chinese products) but all 7' 800x480 tablets shows circles as ellipsis (squares as rectangles), everything is stretched...
Some are Android 2.3.3, others are Android 4.0 but all of them show stretched UI.
Did someone have encountered the same problem?
After some flashing some new builds with changes in the sysconfig1.lhs, I've come to the conclusion that I don't believe there's a solution. The tests I did were on a Allwinner A10 tablet, specifically the M703 model running Android 4.0.4. Note that there are many devices with the same (or similar) hardware configuration but different names.
I dived into the sysconfig1.lhs that's included in the system image, which contains these lines:
lcd_x = 800
lcd_y = 480
And the corresponding touch screen values:
ctp_screen_max_x = 800
ctp_screen_max_y = 480
I measured the screen, which appears to be identical to Seraphim's measurement: 155×86mm. Working with that, I experimented with changing those values to either 864×480, or 800×444.
Unfortunately, neither option solved the issue.
864×480 simply clipped 64 pixels part of the display.
800×444 crashed SystemUI (as it no longer qualifies as sw480dp and therefore expected the device to be phone) and left a 36 pixel gap.
Perhaps the screen resolution needs to be set somewhere else, but I believe that it's the hardware that's somehow misconfigured.
There are many other lines in sysconfig1.lhs that are meaningless to me, such as:
lcd_dclk_freq = 33
lcd_if = 0
lcd_hbp = 46
lcd_ht = 1055
lcd_vbp = 23
lcd_vt = 1050
Perhaps there's some way of changing the pixel ratio, but I haven't experimented.
They are probably either:
not matching the screen physical size with the resolution aspect ratio. What is the physical size (width and height) of the screen?
having non-square physical pixels
If either of that is the case there is not much you can do unless you can do some serious hacking and change the resolution. You get what you pay for I'm afraid.
Does anyone know how to forcefully unload a ByteArray from memory in AS3?
I have tried (without success):
byteArray.length = 0;
byteArray = new ByteArray();
and
for ( var i:int=0; i<byteArray.length; i++ ) {
byteArray[i] = null;
}
Any ideas?
First of all dp != px
Read this http://developer.android.com/guide/practices/screens_support.html
You do not have to provide different layouts for different screen sizes, however the possibility of say a tablet displaying more data over a phone is there - so you may want to give the user more options or show the navigation constantly.
AS for handling images, at the above link, you should take the xhdpi/hdpi size and recreate it at x0.75 (ldpi), normal (mdpi), x1.5 (hdpi) and x2.0 (xhdpi). You then can reference the single image 'R.drawable.logo' and the phone will pick the most appropriate available resource from the relevant drawable folder (e.g. drawable-hdpi).
Plug moment, we have build an alpha tool to do the resizing based on c# .net 2.0 we will publish Alpha version at http://www.wiseman-designs.com/downloads/android-icon-creator/, EDIT: which is free for everyone for anything - source will be released after xmas.
It's caused by Screen Compatibility Mode
http://developer.android.com/guide/practices/screen-compat-mode.html
The only way to avoid it is to use the different drawable folders, but you can just do medium, which is the default, and xlarge and just have Screen Compatibility Mode handle the rest