Questions tagged [screen-density]

128 questions
559
votes
21 answers

getting the screen density programmatically in android?

How to get the screen density programmatically in android? I mean: How to find the screen dpi of the current device?
Praveen
  • 90,477
  • 74
  • 177
  • 219
34
votes
3 answers

Why Nexus 6 density is 560 dpi?

How to prepare resources for Nexus 6? If I put images to xxxhdpi they will scale down and lose quality. I put images to xxhdpi they will scale up and lose quality. Why developers decided setup value 560dpi for density, if real density 493ppi is…
anber
  • 3,463
  • 6
  • 39
  • 68
27
votes
1 answer

Creating an emulator for Galaxy S8? - Android Studio

I create a new hardware profile in an attempt to make and emulator for the Galaxy S8/S8+. I set the screen size to 5.8/6.2 inches (depending on whether S8 or S8+, despite the fact this doesn't appear to affect emulator anyway), and the screen…
4u53r
  • 717
  • 1
  • 7
  • 17
10
votes
0 answers

Android device uses resources from different density sets in debug and signed APK

I noticed that my app shows slightly different layout on the same device depending on whether I am running the debug APK or the signed release APK. After much head scratching, I have isolated the problem to device density specific resource values.…
Amarghosh
  • 58,710
  • 11
  • 92
  • 121
8
votes
2 answers

Layout displayed differently on different devices at the same resolution screen

Problem: layout displayed differently on different devices at the same resolution screen. I tested it on Samsung Galaxy S4 (1080x1920) and on LG G2 (1080x1920). It the same resolution, so why layout is displayed differently on each device ? I have…
5
votes
1 answer

Android how to force screen density by default

By magnifying the screen by "Settings / Displays", I've found that my galaxy s9+'s screen density changes to 430 dpi to somewhere over 600dpi. This makes the layout and images to change to xxhdpi to xxxhdpi. If I have a textView which has the…
March3April4
  • 2,131
  • 1
  • 18
  • 37
5
votes
1 answer

Android xxhdpi, 420 dpi and 480 dpi

I'm facing the next problem: I have a values-xxhdpi with their dimensions.xml. Devices with 480 dpi work great with this folder. The problem is that for example Samsung Galaxy S4 or S5 catch the values from this folder and not look well in screen…
user3240604
  • 407
  • 1
  • 8
  • 22
5
votes
3 answers

Drawing on Canvas issue in high end devices

I want to draw a SeekBar on canvas programmatically. I wrote code to set the LayoutParams of the SeekBar based on device density. I am using switch case with device density like final DisplayMetrics metrics =…
Jas
  • 3,207
  • 2
  • 15
  • 45
5
votes
2 answers

Android screen density dpi vs ppi

According to the android documentation, density should be in dpi (dots per inch) and all layout measurement should be in dp. and using a simple formula android can map dp to actual pixels. px = dp * (dpi / 160), 160dpi ~ medium density screen which…
morfioce
  • 1,107
  • 2
  • 9
  • 12
4
votes
3 answers

Not able to understand how to use different density images for 1.6+?

I'm trying to understand how the res/drawables images should work with different screen densities. Right now I've got a 1.5 app, and for example, I have an image that is 100x100 pixels. When used on the Droid, it scales this image so it appears to…
Mark
  • 39,551
  • 15
  • 41
  • 47
3
votes
1 answer

Effectively Handling Font Size Across Multiple Screen Sizes in Android with Jetpack Compose

What is your usual approach for supporting font size on various devices? While the code below performs well on an Android emulator with mdpi resolution (480x800), it displays large fonts that take up the entire screen on an hdpi device with the same…
Dimitri
  • 123
  • 1
  • 7
3
votes
0 answers

How to display 10cm on web browser no matter the scaling?

I have 27' 4k monitor and would like to present 10cm on the web page as it represented as real dimension in real world. I'm using Windows 10 with scaling set to 175%. Chrome console devicePixelRatio also says: 1.75
broadband
  • 3,266
  • 6
  • 43
  • 73
3
votes
1 answer

Android Splash Screen: Scale Bitmap

I'm basically using the following xml's for an Android Splash Screen: Empty activity with windowBackground: