I'm working with a board wich has android 2.3 as base SO. This board has connected an 7" screen and I¡m using this set to develop an app.
While developing this app on eclipse, I'm using RelativeLayouts. This app will only be for an especific screen size, so for the moment I don have the need to use diferent resolutions to fit other screen sizes.
The problem that I'm getting is that I have developed all this program using on eclipse a 7" screen base, but when runing the app on the board, the layout doesn't fit the screen. It makes the same effect as if you create a layout fitting a 7" screen with RelativeLayouts, and then you change this resolution to 5.4". The layout gets oversized and doesn't fit well the screen.
So, what would be the problem? As i said, the screen is 7" and I'm developing for 7". I don't know why happens this.
Its simple, the pixel density of your board is different from the pixel density of your emulator (on eclipse).
I am assuming you did not set a "fixed" size on your images and layouts, only selecting match_parent for width and height, right?
What is happening is that android is scaling (or not) its resources based on your screen pixel density, and that gives you the difference between the emulator and the board.
Screen size does not means equal screen pixel density, and that can cause you a lot of trouble if you do not manage this correctly providing different resources and qualifiers.
Related
Hi I am making layouts for different screen density in android studio. But I don't know which device should I select in android studio for making ldpi layouts, then which device should I select for making mdpi layouts and so on. Is there any way to calculate screen density of below devices or can you tell it?
Devices available in android studio image
Layout I want
Layout I am getting
All devices list
New hardware as vivo y20g
Thanks
Scroll down in that same window you put a picture of, to "Generic Phones and Tablets". They're all called out for you:
If you need other densities, see the documentation for what each [?]dpi value means and create your own device that matches. A higher density just means you have more pixels per inch of screen. So create a device with a relatively high resolution and relatively low size screen.
I have got an enhancement of one application. It is developed for 10.1 inch tablet. However it is working nice for tabs with size 10.1’ and for other screen sizes UI is poorly aligned. I need to do the changes in application so that it will be as good as 10.1 inch app for all other screen sizes(>4 inches).
I have few doubts here on my approaches.
1) I have found “size qualifiers” in android developer’s site. How many type of layouts need to use for each screen to make good for all sizes in android world.
Note: All screens in this application are always on land scape orientation. Is size qualifiers still works here?
2) Somewhere I found in “stack overflow “, It is already developed for 10.1 inches so that use percentages and change to every screen size.
100% -> 10.1’
? -> 7’
Which one is good and proper solution for maintenance also? Is there any other best solutions?
There is no hard and fast answer.
It is up to you to determine how many screen sizes you want to optimize for.
I'd suggest optimising for small, mid and large with layout qualifiers:
1) size qualifiers do work in landscape as they assess based on smallest screen width.
layout
layout-sw600dp
layout-sw800dp
2) I dont understand your question... i've never seen percentages used in Android layouts
There are so many different screen sizes that you can adapt your layout to..
In Eclipse's graphical layout you can also choose the screen size and resolution for which you want to develop (you can define the screen sizes and resolution and you will see how the layout looks on each of them).
You can also have several images that will be chosen automatically for each screen size via the drawable folder. You got drawable-hdpi for high density screens, drawable-xhdpi for extra high density screens and so on.. you can change an image to adapt to many of the screen size using Google's Android Asset Studio : http://romannurik.github.io/AndroidAssetStudio/index.html
You should also read the Android developers guide:
http://developer.android.com/training/multiscreen/screensizes.html
http://developer.android.com/guide/practices/screens_support.html
it's my first time to develop for Android and I almost finished the app but when I started testing it I faced some problems related to UI. I tested the app while programming it using galaxy s6 edge plus which has a 5.7" 1440x2560 screen, the app has many textviews and I used "sp" units for their text sizes and also used "dp" units for the margins between them. For some textviews I set their backgrounds as a drawable xml in which I set a value for their width and height using "dp" units instead of using wrap_content because I want the backgrounds to be larger than the text inside it so the user can easily touch it. I also made a large-layout folder where I put new xmls inside it with larger fonts so that they work will on tablet and they did, I tested the app on a tablet and it looks great using these xmls and also the app looks great on the 5.7" phone with the normal textviews. Then I tested it on 2 phones with smaller screens each of 5" one of them with Full HD resolution and the other with HD resolution and it looked good on both of them too but when I tested it on a phone with 5" screen but low resolution (480x800) the app looked terrible, textviews interfering with each other and the drawable backgrounds are too big, in short the whole UI is a mess.
What I need to know is whether I also have to test the app for more screen sizes below 5" or for other resolutions too? Because if this is the case then this means so much work!
This is a screenshot of the code for the textview with the drawable background
Thanks in advance
Go through this tutorial: http://developer.android.com/training/basics/supporting-devices/screens.html and this too: http://developer.android.com/training/multiscreen/index.html
I'm sure this will help you out.
If you still encounter any problem, feel free to ask again!
Peace.
I have two sizes of 5.1 inches, a 4-inch for 480x800.
When I design in 5.1 screen and run with 4 inch screen, I have some trouble that some button missed position on screen.
I designed by layout.
Android runs on a variety of devices that offer different screen sizes
and densities. For applications, the Android system provides a
consistent development environment across devices and handles most of
the work to adjust each application's user interface to the screen on
which it is displayed.
Please read below Links
Supporting Multiple Screens
How to support multiple screen in Android
How to support different screen size in android
Supporting multiple screen size - Android
Place your view inside a <ScrollView>. Doing so will mean users with smaller devices will be able to scroll the view if it is too large.
I'm having trouble getting my application to be scalable to different screen sizes on release.
I read through the support documentation at developer.android.com, Supporting Multiple Screens.
At first the app was just using one size version of images that looked fine on my sony xperia (note. with all height & width set to 'wrap_content'). however when I started trying out the emulated devices (ldpi, hdpi & xhdpi) the sizing was not relating to the display.
Below Are Two examples, the first being the correct view. the size & positioning is as expected
The latter is viewed at xhdpi, or the highest resolution that SDK emulator offers.
the positioning is correct, however the sizing is wrong. (sorry about the screenshot size)
I took to my editor & created the images again, one for each display type (mdpi, hdpi, xhdpi) & inserted into the relating resource folders.
I ran the test again, but still had the same sizing issue.
I'm not 100% with this part of android & would appreciate any help or pointers to resolving this issue
p.s please excuse the blanked out sections, they are in place to protect identity.
I don't see anything wrong with the screenshots, a screen with extra high density probably has a very big size (in pixels) so images take a smaller part of the screen. The solution to your problem is to make bigger images for screens with bigger size. From google's Supporting Multiple Screens that you've read you can create a folder like drawable-normal-mdpi for screens with normal size, or drawable-xlarge-mdpi etc etc
It's not an uncommon problem, just make bigger images for bigger screens, I had this issue when dealing with tablets, there was so much empty space because the screen is so much bigger.