Recently i develop an app for Galaxy 10.1 ,7 inch with 1024x600 ,480x800,Note with 800 height abd S3 with 720 height. they are all running perfectly on these resolution. But when we talk about note 2 and galaxy 7 plus and other we got several issues .Which are that the layouts are not correctly seen on these devices. At that iam facing a problem in layouts i use layouts folder for note as layouts-normal-xhdpi-1280x800 and for S3 layouts-normal-xhdpi-1280x720 and put all the layouts in one folder which makes one apk supporting all these layouts.
But when customers download the apk they deal with a problem which was that the Galaxy note picking the layout-normal-xhpi-1280x720 layouts and it was right but S3 and Galaxy Note 2 have different density .
Because of that problem I can't figure out how to declare layout folder for S3 and Note 2. Is there any way that i use only default four folders
Layout Xlarge
Layout Xhdpi with normal
Layout mdpi
Layout hdpi with normal
and supports these all layouts for all screen like S3 ,note 1, note 2, 7 inch plus and others. When i try to start my project i always thought about the big famous games like one of these is "Temple Run" which runs on all mobiles and tabs.
Making bunch of layouts folder make my app heavy like it crosses 80MB limit and Google market only accepts less than 50MB apps.
Pro grammatically is there any way that we use only one layout folder and support this layout on all screens. I read number of articles and android developer portal but they did not satisfy me.They all said you have to make different layouts folder for different screens and even on stackoverflow i saw the same situation for saving my time in first projects I use these techniques but my work is now increasing day by day and i want that i start with those techniques which make my app not heavy because of these bunch of layouts plus not waste my time in making number of layouts for numbers of app.
Number of helps will be appreciated and i want answers and suggestions because these problems are faced by number of developers which are new and others also.
I am also facing such problem in my application. But i found a good solution for this.
I have only one layout for tablet
and directory name is layout-sw600dp
.
Now, when part came to height and width problems, I have created several different values
directory in which i place dimensions
and font size
and other stubs. So there will be no constant
value in layout
of tablet screen.
androd:layout_width:"60dp" // i drop this scenario
androd:layout_width:"@dimen/tab_width" // i used this scenario
and your values
directory name will be like
values-xlarge
values-large
All the values will be fetched from your values directory. It will not create different layout, but one layout can be used multiple times.
Edit:
Following are words of Developer.android
site.
Configuration examples
To help you target some of your designs for different types of devices, here are some numbers for typical screen widths:
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
Using the size qualifiers from table 2, your application can switch between your different layout resources for handsets and tablets using any number you want for width and/or height. For example, if 600dp is the smallest available width supported by your tablet layout, you can provide these two sets of layouts:
res/layout/main_activity.xml # For handsets
res/layout-sw600dp/main_activity.xml # For tablets
===
In this, you can see that, layout for 1280*720 is under layout-sw720dp
so instead of creating layout-normal-xlarge
you should use this thing which lets you to decide differences. Instead of identify differently using layout-large-mdpi
and layout-large-ldpi
, are't you just identify by its smallest width
? Because, android providing drawables
directory for different images, only thing is its resolution. And you have above solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With