Multiple layouts android - android

Im trying to set up my app with several layouts so that it will change depending on screen resolution. So i have a ldpi,mdpi, hdpi and a xhdpi. Everything seems to work in the sense that it changes, but to my question.
Is there a way to manually set which resolution to use which layout? for example now when i run it on my Galaxy nexus, it uses the hdpi layout and that just looks terrible, i want it to use xhdpi
regards,
Fredkr

Why don't you set up your hdpi layout to look the way you would like it to rather than trying to force another layout? Your app will automatically select the layout it should use based on the screen size and pixel density of your phone.

Related

How to make layout compatible with different android devices in android studio?

I am designing an app with a .jpeg background and with text views on particular places on the screen. I designed this for my nexus 6 and used dp for the widths and heights of text views and margin-left and margin-top. What my understanding of dp is that it changes with every device according to screen size and density. So it should work on different phones according to the value of dp for them.
But this is not the case. When I run that app on a different phone (nexus 5) the layout is all messed up. I tried using the different resources and qualifiers for different screens (large, small, normal). But the problem still prevails. The app considers both nexus 6 and nexus 5 as large screens. How do i fix this?
this is not the best solution i guess.
i guess your layout is just on the layout folder. i don't know if the first device you tested the layout is large or small but what you should do is create another folder named layout-sw600dp. this folder is used by tablets. the folder layout is used my phones and smaller devices. you could also create the layout-land and layout-sw600dp-land folders for the landscape orientation.
dp do change depending on the device but if your layout gets messed up then i guess the layout called by that device doesn't fit its resolution. i guess dp becomes smaller if the device is bigger and vice versa.

Android Design Screen for different screen size

app screen on galaxy s4 it skip right and bottom part because of small size mobile
I am having problem in Design different screen size.
how should all 5 categories will support most of the mobile screen?
my Android App Design Normal screen works on 5 inch mobile screen where as for 4 inch screen it skip below content.
for example it work nice on samsang galaxy s4 (5 inch) also on nexus 4.
but as shown in image when i see on nexus S(4 inch screen) it skip some bottom and right part .it cannot hold full layout mostly top and left part it display.
how to design normal screen which support these screen size changes?
is it compulsory to use wrap_content or Match_parent or fill_parent only to get rid of it.
for that also i am confused of specifying image size for different screen size in drawable.
also is normal screen be of different density such as hdpi,mdpi,ldpi etc.
how to solve this issue is it sufficient to use dp and sp?
and last one, in Android Studio we design 5 types of layout.for example activity_channel_list.xml(small). etc( for normal,large,xLarge).what last just activity_channel_list.xml represent.is it like if not any layout is selected.this will be selected by default.
Thanks in advance.
If you want to design layouts for different screens then make folders accordingly link
layout-mdpi
layout-hdpi
layout-xhdpi
layout-xxhdpi
If you don't want create different layout for different screens then simply use dimension file and create different dimens in that like
values-hdpi (dimen)
values-xhdpi (dimen)
values-xxhdpi (dimen)
and the difference between dp and sp is, we use dp for give dimensions to the image, and for size purpose and sp is use for define text size
the screen size id efferent and you cant make a layout for every one you need to try categorize the screen with layout selector
if you use sp for text the text size will change when user change the android font size and it is better to use dp for text
and last Question is like first one you need to categorize layout for size and density normaly
How should all 5 categories will support most of the mobile screen?
Take care if these following aspects while designing layouts:
1.Always design layouts inside scrollview, so that for smaller screens user will be able to view complete layout by scrolling
2.Use sp for text Sizes
3.Use dip(density independent pixels) for all widget sizes, usage of dip makes the size of widget according to mobile profile(like 240*320 may use ldpi so according widget size will change)
4.All the icons you are using you need to generate for all profiles(ldpi,hdpi,xxhdpi,xhdpi) and store in drawable-xxxx folder
If you dont want to generate images for all profiles you can use font icons (like font awesome,iconmoon)
font icons appear according to screen sizes.
5.Last but not least, avoid using hardcoded margins between widgets use attributes like gravity,center_in_parent etc.. so that screen looks uniform in all devices.

Is it necessary to create "small, normal, large and xlarge android xml layouts" folders if i want my application to run of all Android devices

I am developing an Android Application that supports all kind of Android devices like mobiles and tablets. But it's time consuming to create multiple folders (small, normal, large and xlarge android xml layouts) to support all the Android devices. Is there any way to build an android app that runs on all android devices without creating these folders:small, normal, large, xlarge etc?
You only need to create unique layouts (ie. *layout_mdpi* ) if you want something unique for that particular screen size.
If you want to use the same layout on all different screen sizes, you will only need to create a single layout (in the layout folder).
Only if you want to customize a particular layout would you need a new FOLDER in layouts (named: layout_mdpi) in that folder you would have multiple copies of customized layout with same name (ex. my_layout.xml)
To clearly answer your question - you will only need the layout folder and no other ones in your casel
Ex.
res\layout\my_layout.xml // this folder is all you need if this layout will work on all screen sizes
res\layout_mdpi\my_layout.xml // you ONLY need this if you are presenting something unique on this screen size.
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
For More Info refer this
Is there any way to build an android app that runs on all android devices without creating these folders:small, normal, large, xlarge etc
Consider this, you have a button (with match_parent) that stretches full width of a screen in portrait mode of a 4 inch phone, that's fine it looks alright, but then that same layout on a 10 inch tablet in portrait is now 3-4inch wide, that's not great looking.
"So what" you say, make it wrap content, okay then so the button now only fills up part of the width on phone, still looks okay but then on a tablet you have huge amount of space now either side of the button, maybe that's looks okay, maybe not.
Maybe same button on a smaller screen takes up too much space?
Now apply the above to every single layout element in your app.
Do you think it'll look good, using the same layout, do you think your users will be okay with an app that was so little care to its UI and UX?
SO, in conclusion, yeah it's possible to only use one eg normal, for all devices but it'll probably look terrible on most of them.

Android multiscreen different layoutfiles for tablets

I have to make an app which runs on 7" tablets with a resolution of 800x480 and also 1024x600.
The most importan tablet of both is the one with 1024x600 so I placed my layout files in a layoutfolder with the name "layout-sw600dp" and it looks good.
The problem now, is that the tablet with 800x480 resolution is also taking the "layout-sw600dp" folder and my layout isn't looking good. So I have to make some changes, but without destroying the layout for the bigger tablet.
Any idea what I can do?
thanks in advance
Frank
ok found a solution. The problem is, that both tablets are in the same android layout group. So I had to modify my layout in this way to fit for both. I had to use more dp settings and scaletype="fitxy" for images, instead of using "wrap_content".

Android orientation basic question

I am new to android programming. I have a background in my layout file and some image buttons on top. When the orientation of the phone is changed, I dont want the background to change orientation, but I want the image buttons to rotate appropriately. What is the best way to get this functionality?
Also I want to know the resolution of the images for the background for hdpi, mdpi and ldpi. Does it matter if I keep the same pixel size for each of them?
You can read about rotation here: http://developer.android.com/resources/articles/faster-screen-orientation-change.html
There is variety of different resolution for hdpi, mdpi and ldpi. http://developer.android.com/resources/dashboard/screens.html - here you can see what sizes and densities are the most popular. However, you can create layout specially for resolution you need (i.e. several layout for hdpi devices with different resolutions). The most popular resolutions are 320x480, 800x480, 854x480 (often I use the same layout as for 800x480).
You can read about supporting multiple screens here: http://developer.android.com/guide/practices/screens_support.html
No it doesn't matter I think, but can be there some resolution changes, like pixeled parts. I think that the best way to do it, if you make a land suffixed map for your layouts and drawables like: layout-land
Hope it helps!

Categories

Resources