My goal is to create One layout that works for different tablet dimensions.
The app will present the information on Landscape mode.
In my case, I have these two tablets to test, they are 7 inches but with different dimensions:
Acer Iconia One 7 B1-770 Model: A5007
Physical Characteristics
Height: 0.4" (9.5 mm)
Width : 4.3" (108.8 mm)
Depth : 7.4" (189 mm)
Weight (Approximate): 280 g
1024 x 600
Samsung Tab 4 7' Model: SM-T230NU
Dimensions: 186.9 x 107.9 x 9 mm (7.36 x 4.25 x 0.35 in)
Resolution: 800 x 1280 pixels (~216 ppi pixel density)
How can I achieve this goal?
Thanks in advance
You have to create Different values folder for different screens in res folder with folder name Like this
values-sw720dp 10.1” tablet 1280x800 mdpi
values-sw600dp 7.0” tablet 1024x600 mdpi
values-sw480dp 5.4” 480x854 mdpi
values-sw480dp 5.1” 480x800 mdpi
values-xhdpi 4.7” 1280x720 xhdpi
values-xhdpi 4.65” 720x1280 xhdpi
values-hdpi 4.0” 480x800 hdpi
values-hdpi 3.7” 480x854 hdpi
values-mdpi 3.2” 320x480 mdpi
values-ldpi 3.4” 240x432 ldpi
values-ldpi 3.3” 240x400 ldpi
values-ldpi 2.7” 240x320 ldpi
Create layout-sw600dp-land folder with xml file for desired layout.
Add this attribute to your AndroidManifest file.
<supports-screens
android:largeScreens="true"/> //for tablets 7'
Related
I'm running the app on a tablet and I'm seeing the Actionbar is small and also the Bottom menu / tabs have small size how do I increase the size? Is there any style for them that I can override? I did add some style for fitting the tabs into the tablet since they were smaller, how do I increase the size of the actionbar text and the menu/tabs?
Edit
This is how it looks
I had to do this :
<dimen name="design_bottom_navigation_item_max_width" tools:override="true">600dp</dimen>
<dimen name="design_bottom_navigation_active_item_max_width" tools:override="true">600dp</dimen>
To show it on a tablet, but how's the name of the size?
I think you need to specify the dimensions for the tablet
take a look at :
values-sw720dp 10.1” tablet 1280x800 mdpi
values-sw600dp 7.0” tablet 1024x600 mdpi
values-sw480dp 5.4” 480x854 mdpi ,
5.1” 480x800 mdpi
values-xxhdpi 5.5" 1080x1920 xxhdpi
values-xxxhdpi 5.5" 1440x2560 xxxhdpi
values-xhdpi 4.7” 1280x720 xhdpi,
4.65” 1280x720 xhdpi
values-hdpi 4.0” 480x800 hdpi,
3.7” 480x854 hdpi
values-mdpi 3.2” 320x480 mdpi
values-ldpi 3.4” 240x432 ldpi,
3.3” 240x400 ldpi,
i have one app which can be runs on different screen size from 3.7 Inches to 6.0 inches(no plan for tablet now).
now i have TextView which have 17dp for title and 14dp description. but when i run the app in small device (3.7-4.7 inches screen size device) the textview's text is big.
But the same textview in higher 5.5 or 5.7 this can be small .
so how can i make TextView looks same for all device.
I had the same issue and I used this library and it did the thing for me.
The thing is you just have to replace sp with ssp in your xml after adding this library in your gradle and you'll be good to go.
As screen size is between 3.7 and 6.0 you should only create 1 additional dimens files like sw480 and use dp-s for TextView dimensions and sp for text size. In default dimens file you should write sizes for devices with smallest screen sizes e.g. for 3.7‘, and comparably bigger dimens in sw480 file e.g for 5.5‘ screens. Based on particular cases additional dimens files can be created like sw360. If screen is less than 360 dp width,it will use the values from default dimens file, if 360dp <= screen size < 480dp then sw360 will be used. The same simple logic works for each created sw dimens file.
Create multiple dimens.xml for your project, it will give size according to the display size
You Have to create multiple values folder and have to create dimens.xml inside them.
A reference for those folders are:
values-sw720dp 10.1” tablet 1280x800 mdpi
values-sw600dp 7.0” tablet 1024x600 mdpi
values-sw480dp 5.4” 480x854 mdpi
values-sw480dp 5.1” 480x800 mdpi
values-xxhdpi 5.5" 1080x1920 xxhdpi
values-xxxhdpi 5.5" 1440x2560 xxxhdpi
values-xhdpi 4.7” 1280x720 xhdpi
values-xhdpi 4.65” 720x1280 xhdpi
values-hdpi 4.0” 480x800 hdpi
values-hdpi 3.7” 480x854 hdpi
values-mdpi 3.2” 320x480 mdpi
values-ldpi 3.4” 240x432 ldpi
values-ldpi 3.3” 240x400 ldpi
values-ldpi 2.7” 240x320 ldpi
In android you are dealing with dp/sp values. Don't think of physical size.
There's this nifty plugin that lets you convert your sp/dp values to different buckets. You can add
https://plugins.jetbrains.com/plugin/9349-dimenify
I am generateing list of app icons at runtime process and storing it in a Drawable object like this:
Drawable d = getPackageManager().getApplicationIcon("package name");
my_imageView.setImageDrawable(d);
}
It looks perfect in my screen size device (4.5 inch) as I want but when I test it out in larger screen size device like 5,5.5,6 inch screen it looks big. I want it to look same size as it looks in my screen on all screen sizes. Is it possible.Thanks in advance
Here is my xml:
<ImageView android:layout_height="50dp"
android:layout_width="50dp"
android:scaleType="fitXY"
android:padding="1dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:id="#+id/imageViewicons"/>
When we talked about supporting different screen size in Android. Everyone is focusing on creating different layouts for every possible screens i.e.
ldpi
mdpi
hdpi
xhdpi
xxhdpi
xxxhdpi
You have to create Different values folder for different screens . Like
values-sw720dp 10.1” tablet 1280x800 mdpi
values-sw600dp 7.0” tablet 1024x600 mdpi
values-sw480dp 5.4” 480x854 mdpi
values-sw480dp 5.1” 480x800 mdpi
values-xhdpi 4.7” 1280x720 xhdpi
values-xhdpi 4.65” 720x1280 xhdpi
values-hdpi 4.0” 480x800 hdpi
values-hdpi 3.7” 480x854 hdpi
values-mdpi 3.2” 320x480 mdpi
values-ldpi 3.4” 240x432 ldpi
values-ldpi 3.3” 240x400 ldpi
values-ldpi 2.7” 240x320 ldpi
For More information you can visit here
Try putting the object in an android layout as these scale with the size of the screen.
but if you want something complex that isnt possible in the layouts you would have to use the Values method.
I provided different xml layouts (with same name) for different screen sizes - like layout-sw320dp, layout-sw480dp etc.
But when I try to change some properties in the specific layout in order to adapt UI for different devices - for example layout_height, layout_width, paddingRight, topMargin and so on - it still doesn't look good.
I suppouse that's because there is a screen sizes range (4-5") and different screen sizes read from layout-sw320dp. I tried on Galaxy S4 - 5" screen and on Galaxy S3 Mini - 4" screen. So on S4 evrything looks good but on S3 mini - doesn't - buttons are moved down, image not in the center.
What am I doing wrong?
Thank you in advance!
Use dimens.xml to assign Widths,Margins,padding. This xml is available in res/values folder. for different devices u can create different dimens. It simalar to having differnt Images for differnt Devices.
Source
You have to create Different values folder for different screens . Like
values-sw720dp 10.1” tablet 1280x800 mdpi
values-sw600dp 7.0” tablet 1024x600 mdpi
values-sw480dp 5.4” 480x854 mdpi
values-sw480dp 5.1” 480x800 mdpi
values-xhdpi 4.7” 1280x720 xhdpi
values-xhdpi 4.65” 720x1280 xhdpi
values-hdpi 4.0” 480x800 hdpi
values-hdpi 3.7” 480x854 hdpi
values-mdpi 3.2” 320x480 mdpi
values-ldpi 3.4” 240x432 ldpi
values-ldpi 3.3” 240x400 ldpi
values-ldpi 2.7” 240x320 ldpi
Check this Image :-
I'm trying to display an image in an ImageView on 10' lenovo yoga. In each drawable folder I have put an instance of the same image with different sizes:
ldpi: 184 x 294
mdpi: 248 x 397
hdpi: 375 x 600
xhdpi: 496 x 794
xxhdpi: 800 x 1280
The images are the screenshots I've taken with the same device with xxhdpi image being the original image. The problem is instead of loading the image from a high res folder it is loading the image from mdpi and thus the result is blurry. Why is it doing this?
The drawable folders refer to screen density I believe. At http://developer.android.com/guide/practices/screens_support.html it says,
A set of six generalized densities:
ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpi
I looked up the specs of the 10' lenovo yoga and depending on the one you own, the screen density will be different. For example the Yoga 10 has 149 ppi and the lenovo yoga 2 pro has 276 ppi. So that could be the reason why it's pulling from the lower resolution drawable folders.