android screen size not scaling - android

I'm trying to support multiple screen sizes but I'm obviously missing something
I'm testing between a Samsung Galaxy Tab Pro (10.1 Tablet) and Samsung Note 3 (phone/fab)
DisplayMetrics WidthPixels HeightPixels Density DensityDPI
Tab Pro reports 2560 1600 2.0 320
Note 3 reports 1920 1080 3.0 480
I have all the layouts in /res/layouts and They all start with
RelativeLayout match_parent for layout_width and layout_height
My AndroidManifest.xml has
Ideally I would like to support screen resolutions of 1024 x 768 and larger
Which both the Note 3 (at 1920x1080) and Tab Pro (at 2560x1600) are
On the Tab Pro everything lays out the way I would like
On the Note 3 you are only seeing the upper left corner of the screen
It is almost as if the Tablet Layout has been cut in quarters
Y X
X X
And the Note 3 shows the Y only while the Tab Pro shows it all
Please help ? ?
Thanks in advance

Related

Android spacing issue in same resolution devices 1080x1920

I am designing screen from Zeplin. (Zeplin provides each item attributes in dp)
Following is the horizontal recycler view design example with 4 items from Zeplin.
360 dp means 1080 for xxhdpi devices
I am testing my code on two 1080 devices with different dpi
Samsung c5 [1080 x 1920 pixels, 16:9 ratio (480dpi)]
Nexus 5X [1080 x 1920 pixels, 16:9 ratio (420dpi)]
I am facing spacing issue in Nexus-5x, the Zeplin design works great
on Samsung-c5.
Samsung-c5 result
Nexus-5x result - spacing issue in horizontal recycler view
QUESTION:
Why the design in different on same resolution (1080x1920) devices (different dpi). How can I make it look same on each and every device like facebook does with its status
Similar Questions:
How to use 1080x1920: 420 dpi - Android studio
Android xxhdpi, 420 dpi and 480 dpi
XXHDPI Layout different on different XXHDPI devices
Sol1 - Calculator app different layout on same screen size but different DPI (420 DPI vs 480 DPI) - Android Developer
Sol2 - Android layout folders for different screen sizes
Placing dimens in values-w410dp worked, as mentioned in the answer here

Creating a Responsive Design

Hey guys I'm dealing with responsive design on Android with specifications below:
My app should not scroll.
I want to design it for all existing devices.
For now I opt for values/dimens file that I created for all dimension aspect in the app.
So I created w480dp, w300dp for widths and h750dp and h400dp for heights.
When I test my app in emulators:
320X480 Mdpi
480 x 854 Mdpi
480 x 800 Hdpi
768 x 1280 Xhdpi
They tooks all the w300dp X h400dp
In my testing device (galaxy S6 1440x2560) it took also w300dp X h400dp.
Anyone can tell me what qualifier should I use or even if I have a comprehension issue.

How to create different layout for Galaxy S4 and Nexus 4

I am using "layout-sw360dp" for both Galaxy S4 and Nexus 4 devices but in my screen displaying some space on Galaxy S4. so can i make different layout for both Galaxy S4 and Nexus 4. if it is possible then please give me the solution.
For Galaxy s4 use layout-xxhdpi
For Nexus 4 use layout-xhdpi
Galaxy S4 -- 1080 x 1920 pixels -- 5.0" -- 441 ppi -- xxhdpi
Nexus 4 -- 1280 x 768 pixels -- 4.7" -- 320 ppi -- xhdpi
You have to make different images to fit to the resolution of these devices
As per other answers one device is 640 x 360 dp and the other 640 x 384 dp.
You don't want to make a different layout for them, because you will sooner or later see a device 640 x 372 dp or 640 x 388 dp.
Instead make your layout elastic and don't hardcode pixels (density independent pixels can also be badly hardcoded).
ok here goes...
for reference
this is older layout folder naming conventions but you get the point.
You must convert everything to mdpi to go into the following buckets.
buckets for layouts are :
xlarge 960 x720 min
large 640 x480 min
normal 470 x 320 min
small 426x 320 min
scaling ratio
3:4:6:8:12
this means that you must multiple ldpi * 3/4 to go from ldpi to mdpi
and you must multiple mdpi * 4/6 to go from mdpi to hdpi
and you must multiple hdpi * 6/8 to go from hdpi to xhdpi
and you must multiple xhdpi * 8/12 to go from xhdpi to xxhdpi
so to answer the question....
s4 is xxhdpi which means the scaling ratio is 4/12 or 1/3. This means that you have to convert from xxhdpi to mdpi to place in a layout folder properly.
so 1080 * 1/3 = 360
and 1920 * 1/3 = 640
so this would place it in a normal layout folder
nexus 4 is xhdpi which means the scaling ratio is 4/8 or 1/2. 4 This means that you have to convert from xhdpi to mdpi to place in a layout folder properly.
so 1280 * 1/2 = 640
and 768 * 1/2 = 384
so this would place it in a normal layout folder as well.
ok, so this doesn't quite cut it because they are different resolutions. we can make up folders with the new naming conventions. for example the smallest width for the s4 is 360 while the smallest width for the nexus 4 is 384. so folders could be sw360dp and sw384dp.
you could also name the folder layout-xxhdpi which would catch the s4 but not the nexus 4
be aware: Just to throw another one out there what if you had an s3 as well. that would go in the sw360dp folder as well. so I guess you would have to differ between them as well. if you used layout-xxhdpi above then you could use sw360dp here and sw384dp above as well. cover them all.
thanks
Both these phones have different screen size and resolution , that leads to different density as well .
As per my knowledge -
Galaxy s4 has 1080 x 1920 pixels, 5.0 inches (~441 ppi pixel density).
And
Nexus 4 has 1280 x 768 pixels, 4.7 inches (320 ppi ).
You will have to design the layouts (and images as well ) according to the phones specifications.
for nexus 4 use below layout.
layout-sw360dp
both galaxy s3 and nexus 4 have same layouts.

How to create different layout for Nexus 4 and similar devices? (Galaxy S4)

The question is how create a specific layout for Nexus 4 and similar devices?
4.7" diagonal
1280 x 768 pixel resolution (320 ppi)
WXGA IPS
For Nexus 4 should load the same layout that Galaxy S3
Galaxy S3
Screen Size: 4.8 inch
Screen Resolution: 1,280 x 720 pixels
And the configuration should be:
For same layout landscape and portrait layout-sw360dp
Only for landscape layout-sw360dp-land
Only for portrait layout-sw360dp-port
Other similar devices:
LG Optimus 4X HD
HTC One X+
For Galaxy S4 should also compatible and load this layout
The response was in this entry: Android S3 layout vs Galaxy Nexus layout
You can create layout directories for specific combinations. For 7" 1280 x 768 at 320 ppi it will look something like this:
layout-sw600p-xdpi-large
As #Tomer Mor mentioned, you can find a full list of available parameters here
Also, if you want to be even more specific about device parameters, take a look at this question - you can assign different layouts from code, depending on the environment.

Android Tablet Dimensions

We have just started Android Tablet development. I need to prototype for 7in and 10in tablets.
Is there any wireframe stencil i can get hold of ?
What are the dimensions of the canvas i need to start designing on ?
Just like phones, tablets have all sorts of dimensions and sizes.
Here is a quick list of different models with their respective sizes and dimensions:
Samsung Galaxy Tab 10.1 3G - 10.1 inches, 1280 x 800 pixels
Samsung P1000 Galaxy Tab - 7.0 inches, 600 x 1024 pixels
Dell Streak 7 - 7-inch 800×480
Motorola Xoom - 10.1-inch, 1280×800
Viewsonic G - 10.1-inchs 1024×600
These are the dimensions you'll find most often.
Rather than considering actual pixel dimensions (which can vary in size depending on pixel density), it might be easier to think in density independent pixels (dp). This is the smallest device width as given in the configuration examples from the docs:
7” tablet: 600dp
10” tablet: 720dp
Notes
For actual pixels size, multiply by 1 to get mdpi, multiple by 2 to get xhdpi, by 3 to get xxhdpi, etc. See here for more.
To provide different resources for the various screen sizes, see this answer.
Old topic but i think i've got a good way to resolve your probleme. If it can help some..
First of all, if you do right, All your activities should be composed ONLY with fragments.
You may know that when a screenSize is defined as exemple by 384* 640, that means your maxWidth is 384dp and your maxHeight is 640dp.
And so, it's easy to determine how height you should use without trying on emulator.
Still using my screenSize exemple : 384 (Widht) * 640 (Height) :
640dp
292dp
264dp '
<dimen name="max_height">640dp</dimen> <!-- screen maxHeight -->
<dimen name="half_height">292dp</dimen> <!-- ScreenMaxHeight with actionBar -->
<dimen name="half_height_bigactionbar">264dp</dimen> <!-- height without actionBar and its subActionBar -->
Down here, this is my fragment size :
<fragment
android:layout_width="match_parent"
android:layout_height="#dimen/half_height_bigactionbar"
Both of my fragmennts should now fill all the sreen
My action bar height is 56dp . If you do the map if i want he half of my screen i do ((maxScreenHeight) - (ToolBarSize) ) / 2.
I got ((640) - (56)) / 2 = 292dp !
Do the same for All of resolution you might know with all the window part you may use:
And you will have THE perfect match in every phone you know.
You can do the same math for width if you use tablet.
But remember, use as much as possible wrap_content + marginLeft and MarginRight to place your components !
When you wana create an activity. Draw it in a sheetwith small-paned . And think only with percent. Then do the math, and use ONLY fragments.
You should be fine then :). Ask if i wasn't clear enought !

Categories

Resources