Button moves up when I launch app on Nexus4 ADV - android

I made my android app, a background, and some buttons. I run the app on my Galaxy S Device, and it's ok as I designed the buttons are where I put them. When I start the same app on virtual device Nexus4, the buttons always move a little up.
What is the cause? What can I do, so on all devices buttons to stay on the same place?

the problem might be that you may use your own defined sizes for buttons like
android:layout_width="80dp"
android:layout_height="40dp"
and layout_marginTop,Left,Rigth attributes
because supplying our own values varies for different screen orientations from small screen mobiles to large screen tablets
best culture the habits of using wrap_content,fill_parent,match_parent
and layout_weightsum for Linear layouts

As android is running on multiple devices with multiple screen with different resolutions, here is how to support them: Supporting Multiple Screens
Basically we have following screens resolution:
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
to support them all, in Res folder we have to create folders depending what screens we want to support.
layout-xlarge
layout-large
layout-normal
layout-small
after, copy the your final layout_file.xml to all of them, open it in Graphical mode, and rearrange the buttons to look good on the screen. Depending on the resolution screen android will choose layout which is closer to device resolution . Just test it on different devices, or virtual devices to make sure it looks good.

Related

Android: Difference Between Large and Xlarge Layout?

I have an app that I am creating. I want to have this app support tablets, so I created a folder in my res: res/layout-xlarge/my_layout.xml. However, when I run my app on a tablet (defined as 7" or above) the layouts are not used from the layout-xlarge folder, but instead from the layout folder.
I then discovered that there were also layout-large layouts that I could use too. I haven't yet tried them, but I will.
I would like to know what is the difference between layout files, layout-large files and layout-xlarge files. Which one would be the best to use for tablet layouts?
Thanks!
From Android documentation - Supporting Multiple Screens:
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
Which one to use, as you can see, depends on the dimensions of the device you're aiming for. You probably want to build your app so it will support as much devices as possible.
In Android we need to maintain different folders for the layouts with different resolution reason behind it is the use or the resolution of the Android Device on which the application gonna execute.
small Resources for small size screens.
normal Resources for normal size screens. (This is the baseline size.)
large Resources for large size screens.
xlarge Resources for extra large size screens.
Android OS select the specific layout it self by checking the compatible device and its resolution.
So, better to create folders to support in multiple screens

Supporting different screens, based on the dimension or based on the dpi?

I use API 7. I know there are two ways for my question:
1- using the layout-small and layout-normal and layout-large and layout-xlarge.
2- using the sw-320dpi and like this.
When I see the all existing devices (tablet and phones) in the android studio, I understand it does not contain the all existing devices (tablet and phones) in marketplaces. Now I want know your experience about my question. If you want create an application that it uses the API 7, Which method you choose? I do not want link from other websites, I want know your experience about supporting different screens? What is the best way?
you use api level 7 so you should use :
layout-small, layout-normal, layout-large and layout-xlarge.
because using sw-320dp ... begins with android 3.2(api level 13)
Take a look :
Beginning with Android 3.2 (API level 13), the above size groups are deprecated and you should instead use the swdp configuration qualifier to define the smallest available width required by your layout resources. For example, if your multi-pane tablet layout requires at least 600dp of screen width, you should place it in layout-sw600dp/. Using the new techniques for declaring layout resources is discussed further in the section about Declaring Tablet Layouts for Android 3.2.
http://developer.android.com/guide/practices/screens_support.html
It's not sw320dpi, but sw320dp. This number doesn't represent screen density, but size in the same manner as small/normal etc.
See http://developer.android.com/guide/practices/screens_support.html
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp

Android Screen Resolution for xlarge

i developed an android appplication. and i want to test this application for xlarge screens.
when i tried to create an emulator with the following resolutions the emulators are not loading
is there any way to test the application for xlarge screens
I tried with the following resolutions:
hdpi-
1536x1152
1920x1152
1920x1200
xhdpi-
2048x1536
2560x1536
2560x1600
my monitor is Dell-21" with resolution Max-1600*900.
There are specific Android API calls that can, at runtime tell you what density and (small/large/normal) screen size a handset has. However, as a developer we should not need to worry about individual handsets at all. All we need to do is to have ldpi/mdpi/hdpi assets and small/normal/large layouts in the apk. Android internally handles everything.
Dont forget to get an indepth understanding of how Android determines which assets to use and aliasing like this.
The definitions are:
xlarge screens are at least 960dp x 720dp.
large screens are at least 640dp x 480dp.
normal screens are at least 470dp x 320dp.
small screens are at least 426dp x 320dp. (Android does not currently support screens smaller than this.)
Here are some more examples of how this works with real screens:
A QVGA screen is 320x240 ldpi. Converting to mdpi (a 4/3 scaling factor) gives us 426dp x 320dp; this matches the minimum size above for the small screen bucket.
The Xoom is a typical 10” tablet with a 1280x800 mdpi screen. This places it into the xlarge screen bucket.
The Dell Streak is a 800x480 mdpi screen. This places it into the bottom of the large size bucket.
A typical 7” tablet has a 1024x600 mdpi screen. This also counts as a large screen.
i want to test this application for xlarge screens. when i tried to
create an emulator with the following resolutions the emulators are
not loading is there any way to test the application for xlarge
screens
AFAIK you can Only create Emulator With Given Below suggestions with Density
While Creating AVD you will get Below Image. you can only choose from the Below Devices to make your Emulator.
Your Alternative Solution :
However, I need to ensure everything's fine.
Yes you can Surely get what you want.
if you want to Check whether your application runs perfectly on 960x640(Normal screen xhdpi) Device. you can Make Custom Configuration From Below Suggestion.
After Update your ADT to version 21.
In Older Version each time you have to set Add Custom Screen if you want custom Device Configurations as (if you want Nexus 4).
In ADT21 version you can get this thing done by
open AVD Manager, u can define your custom screen in "Device Definition"
Alternative (Much Easier approach)
in Newest Version you Don't Need to Set Custom Device
Configurations from the above Suggestion as much easier way is available for it. you >Just Have to Make Emulator With your Device
Configurations and after you will see those Configurations with
Emulator Name Inside Graphical Layout of XML
like after Created my Emulator of Nexus7 Emulator with Android 4.2 with Name as "Nexus7_Android_4.2" i will get this Device Configuration in Graphical Layout of xml automatically.
Below is the Screen Shot of it.
Hope it will Help you.
In emulator ie in AVD->Device Definition.You can select and fix any type of resolution. You
can also customise any type of size. Since it takes time to load due to high resolution in
emulator.

Android not using right layout according to screen size

So I have two sets of layout, one for a 7inch tablet, one for a 10 inch tablet.
Configuration.SCREENLAYOUT_SIZE_MASK
shows large for the 7, xlarge for the 10 device. I created two folders, layout-large and layout-xlarge, but the 7inch device uses the x-large layouts (I even deleted the normal layout folder).
What could be my problem here?
EDIT: I also tried the new qualifiers according to http://developer.android.com/guide/practices/screens_support.html#DeclaringTabletLayouts, making the layout folder for the 10"
layoutw1280dp
which the 7" cannot possiblys have, still the same.
Don't underestimate how many pixels these small screens can have. The Samsung Galaxy S3 has 720x1280 screen. That screen couldn't be larger than 7"
From the documentation:
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
Which tablet is it?
Sorry bothering you guys, obviously it was not an Android problem, but an Eclipse one, somehow the layout files within the folders got mixed up when I imported the project.

Best way to test Android app in Eclipse simulator emulating different Screen devices

I found out the hard way that in certain cases it is much better to define the screen layout in two different xml files rather than trying to write one univeral xml suitable for all screen specs.
normal 640dp x 480dp in -> layout folder
small 470dp x 320dp separately in -> layout-small folder
While testing works well with different Android real phones I would like to also test emulating in simulator. For example I found that the normal layout works on a Samsung Galaxy but not on HTC (having the same screen dimensions - I think).
Is there a reliable way to test the layout in emulation mode for specific phones? How and where do I define the settings?
ps when defining the xml there are the options for different screens on top of the window - however in many cases this does not work and/or is not reliable (eg when there is text in a textfield) - and it's only for editing not for simulation.
Many thanks
If you are using windows and have installed the Android SDK you should see a "Android SDK Tools">"SDK Manager" in start menu. There you can edit screen resolutions of all emulators (AVD's) that you have installed. And you can create new ones too. You should be able to select any of these in Eclipse's launch-menu.
You don't really say what the problem is you're having - you can't really 'simulate' an HTC phone in the emulator because you aren't running SENSE on that emulator?
I also think you might be misunderstanding or assuming too much in terms of what the layout-[resources] mean...
Taken from http://developer.android.com/guide/practices/screens_support.html
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
Note the 'at least' bit.
The HTC Wildfire is 320x480 - the HTC Desire is 480x800 - not that they're different 'ratios' - something the layout isn't going to be able to get around for you...

Categories

Resources