Multi-Screen Setting [duplicate] - android

This question already has answers here:
How to define dimens.xml for every different screen size in android?
(10 answers)
Closed 5 years ago.
I have an images of size (width = 1444 * height = 760). Now i want to show it in imageview to set imageview weight and height i create different file for dimens.xml like:
dimens.xml
dimens.xml(hdpi)
dimens.xml(mdpi)
dimens.xml(xhdpi)
dimens.xml(xxhdpi)
dimens.xml(xxxhdpi)
dimens.xml(sw600dpi)
dimens.xml(sw720hdpi)
Now to set the image-view height and width. what size value to put in which dimens.xml file please help and sorry for English mistakes if any...

try this:
LDPI: Portrait: 200 X 320px
MDPI: Portrait: 320 X 480px
HDPI: Portrait: 480 X 800px
XHDPI: Portrait: 720 X 1280px
XXHDPI: Portrait: 960 X 1600px
XXXHDPI: Portrait: 1440 x 2560px

Related

Understanding Drawables and Images sizes

Firstly I did a lot of search to understand how it work, but I don't find simples tutorials. An exemple, this view:
These are my drawables folders:
The selected device is: Pixel 5.0 1080 x 1920 (xxhdpi).
Immagine in this resolution (1080 x 1920) I set the image view on the top in blue color (Solutis) with 700px of width and 250 px of height, how I have to resize this images for each drawables folders ?
I found this informations:
LDPI - 0.75x
MDPI - Original size // means 1.0x here
HDPI - 1.5x
XHDPI - 2.0x
XXHDPI - 3x
XXXHDPI - 4.0x
And
LDPI: Portrait: 200 X 320px
MDPI: Portrait: 320 X 480px
HDPI: Portrait: 480 X 800px
XHDPI: Portrait: 720 X 1280px
XXHDPI: Portrait: 960 X 1600px
XXXHDPI: Portrait: 1440 x 2560px
Here I don't understand why when I select my vistuel device 1080 x 1920px on the Design Edit it say xxhdpi and xxhdpi is 960 X 1600px...
And what gonna be the different sizes of the image for the differents drawables ?
If someone can publish a project exemple, I wool look on, please.
Did you check the documentation? Here is the interesting part:
Density-independent pixel (dp)
A virtual pixel unit that you should use when defining UI layout, to express layout dimensions or position in a density-independent way.
The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a "medium" density screen. At runtime, the system transparently handles any scaling of the dp units, as necessary, based on the actual density of the screen in use. The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160). For example, on a 240 dpi screen, 1 dp equals 1.5 physical pixels. You should always use dp units when defining your application's UI, to ensure proper display of your UI on screens with different densities.
This means if your device as a higher density a bigger image will been chosen.

Allocated Memory (RAM) in Android Studio. Is it normal?

I have created an Android application that contains 6 imageviews, and some texts.. the size of the APK file is about (2 Megabyte). When I run the application of a real Android Device (HTC One M8-eye) it takes about (66 MegaByte) RAM of the device (Allocated Memory).
I also used (leakcanary), and the result is (there is no leak) in this app.
Is it normal?
is there any suggestions to reduce this size??
Any answer is appreciated..
Thanks
This problem can be solved by creating different drawable folders (LDPI, MDPI, HDPI, XHDPI, XXHDPI, XXXHDPI).
I also used the (android drawable importer plugin) to import photos and generate different sizes and put them to different drawable folders.
Following are some important information:
LDPI: Portrait: 200 X 320px. Landscape: 320 X 200px.
MDPI: Portrait: 320 X 480px. Landscape: 480 X 320px.
HDPI: Portrait: 480 X 800px. Landscape: 800 X 480px.
XHDPI: Portrait: 720 X 1280px. Landscape: 1280 X 720px.
XXHDPI: Portrait: 960 X 1600px. Landscape: 1600 X 960px.
XXXHDPI: Portrait: 1280 X 1920px. Landscape: 1920 X 1280px.
The Result:: Used ammount of RAM is reduced from 60 Mega to about 13 Mega.

what are correct sizes for navigation drawer header images?

I want to set an image as navigation drawer header image, but I don't know the correct sizes to fit all devices. What are the correct sizes in pixels?
From the answer given by Angad Singh to this question: Background image dimension for Navigation Drawer header, these are the dimensions:
mdpi: 384 x 216 px
hdpi: 576 x 324 px
xhdpi: 768 x 432 px
xxhdpi: 1152 x 648 px
xxxhdpi: 1728 x 972 px
Note that all sizes follow a 16:9 ratio, as requested by material design guidelines. The xxxhdpi could be optional, as the image could be too large and it seems not even Google uses this size in some of their apps (I'm not using it on my app either).
You can find navigation drawer specs here:
https://www.google.com/design/spec/patterns/navigation-drawer.html

Image resolution for mdpi, hdpi, xhdpi and xxhdpi

I have a background for my app in resolutions 720x1280 pixels, 1080x1920 pixels and 1440x2560 pixels.
In which folders (mdpi, hdpi, xhdpi and xxhdpi) should I put each background?
Please read the Android Documentation regarding screen sizes.
From a base image size, there is a 3:4:6:8:12:16 scaling ratio in drawable size by DPI.
LDPI - 0.75x
MDPI - Original size // means 1.0x here
HDPI - 1.5x
XHDPI - 2.0x
XXHDPI - 3x
XXXHDPI - 4.0x
For example, 100x100px image on a MDPI will be the same size of a 200x200px on a XHDPI screen.
Require Screen sizes for splash :
LDPI: Portrait: 200 X 320px
MDPI: Portrait: 320 X 480px
HDPI: Portrait: 480 X 800px
XHDPI: Portrait: 720 X 1280px
XXHDPI: Portrait: 960 X 1600px
XXXHDPI: Portrait: 1440 x 2560px
Require icon Sizes for App :
http://iconhandbook.co.uk/reference/chart/android/
DP size of any device is (actual resolution / density conversion factor).
Density conversion factor for density buckets are as follows:
ldpi: 0.75
mdpi: 1.0 (base density)
hdpi: 1.5
xhdpi: 2.0
xxhdpi: 3.0
xxxhdpi: 4.0
Examples of resolution/density conversion to DP:
ldpi device of 240 X 320 px will be of 320 X 426.66 DP. 240 / 0.75 = 320 dp 320 / 0.75 = 426.66 dp
xxhdpi device of 1080 x 1920 pixels (Samsung S4, S5) will be of 360 X 640 dp. 1080 / 3 = 360 dp 1920 / 3 = 640 dp
This image show more:
For more details about DIP read here.
Check the image above I hope it will help someone.
Link to the whole article itself
Your inputs lack one important information of device dimension.
Suppose now popular phone is 6 inch(the diagonal of the display), you will have following results
DPI: Dots per inch - number of dots(pixels) per segment(line) of 1 inch.
DPI=Diagonal/Device size
Scaling Ratio= Real DPI/160.
160 is basic density (MHDPI)
DP: (Density-independent Pixel)=1/160 inch, think of it as a measurement unit
in order to know the phone resolution simply create a image with label mdpi, hdpi, xhdpi and xxhdpi. put these images in respective folder like mdpi, hdpi, xhdpi and xxhdpi. create a image view in layout and load this image.
the phone will load the respective image from a specific folder. by this you will get the phone resolution or *dpi it is using.

How can I calculate phone's width and height in density pixels

For instance, I have a Galaxy Tab 2 http://www.gsmarena.com/samsung_galaxy_tab_2_10_1_p5100-4567.php which has display size 800 x 1280 pixels
How can I calculate with and height in dp?
I want to use relevant values in resource folder names
values-sw600dp
Galaxy Tab 2 has 10.1" display and 800 x 1280.
For sw (smallest width):
800 / (141/160) = 800 / 0.88125 = 907.8 dp -> so it fits to for example into sw600dp.
141 - DPI of screen
160 - DPI of MDPI screen
800 - pixels in width
Basicaly sw-600dp fits to 7" tablets and sw-720dp fits to 10" tablets.

Categories

Resources