Questions tagged [density-independent-pixel]

DIP is short for Density Independent Pixel. It is used by the Android system as a unit of measurement to make GUIs fit on different screen sizes with scaling. This allows the developer to create a single interface for different screen sizes.

119 questions
6
votes
4 answers

How to calculate the pixel density (dp) of a device?

What is the independent pixel density for a Galaxy s4? I need it so I can have a qualifier sw???dp for that phone. It would be great if you could explain how to calculate it.
LittleFunny
  • 8,155
  • 15
  • 87
  • 198
5
votes
1 answer

How do I convert to DIP?

What is the formula for converting regular pixels to DIP? Assuming I have a photoshop document with a design in it that was intended for the Galaxy Tab (for example) which is 600x1024 actual pixels. What is the ratio between those and the DIP? I'm…
Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236
5
votes
3 answers

How to find what density bucket the phone is in?

Slightly noob-ish question but I get confused when it comes to calculating what density bucket the phone falls in. I'll take my Galaxy S3 as an example. It has a resolution of 1280 x 720 which means it has 306 dpi. Now, referring to the chart…
An SO User
  • 24,612
  • 35
  • 133
  • 221
5
votes
4 answers

Pixels to dips, desktop and android

I am using Libgdx to code an android game and as you may know, many screen resolutions cause some problems if done incorrectly. So I am trying to use this DP unit rather than pixels. However, I have this method here: public static float…
Gibbo
  • 630
  • 1
  • 8
  • 22
4
votes
3 answers

android Imageview layoutparams in dip?

I'm using the following code : ImageView i = new ImageView(mContext); i.setImageResource(mImageIds[position]); i.setScaleType(ImageView.ScaleType.FIT_XY); //pixels settings !!! i.setLayoutParams(new Gallery.LayoutParams(200, 100)); but as…
Fabien
  • 1,967
  • 8
  • 30
  • 42
4
votes
3 answers

Getting screen width Android in dips

I want to get the screen width , and set it to my layout which is a child of a Horizontal Scroll View . I am doing this but it makes my layout wider than I want . padding is defined with dips. Display display =…
user3199577
  • 249
  • 2
  • 5
  • 14
4
votes
2 answers

How can I use custom tiles that are adapted to the device's pixel density in Google Maps API in Android?

I am writing a Android app that includes a map using the Google Maps API. I load custom map tiles using a my own extension of com.google.android.gms.maps.model.UrlTileProvider. I have two sets of map tiles: one designed for higher density screens…
4
votes
2 answers

setLayoutParams dip values

I am trying to use the method setLayoutParams in order to specify the graphical parameters of my table layout, but I am not sure whether the method setLayoutParams takes pixel values, or dip values, especially that in java the values stored seem to…
akari
  • 617
  • 1
  • 11
  • 32
4
votes
2 answers

Converting dip to pixels yielding the same value

I need to convert density independent pixels to pixels in my activity. I tried using this method in my onCreate float pix = dipValue * getResources().getDisplayMetrics().density; pixel = Math.round(pix); I tried another method Resources r =…
darsh
  • 741
  • 4
  • 10
  • 34
3
votes
1 answer

HorizontalOffset goes in the wrong direction for High DPI primary screen

I am currently working on some high DPI issues in our WPF app (.NET 4.6.1 - System DPI-awareness is active). Generally the app does what we expect it to do - scale depending on the current displays DPI setting, also when moving it from screen A @…
Christoph Fink
  • 22,727
  • 9
  • 68
  • 113
3
votes
0 answers

javafx how to achieve density independent design

 Hello all,                 We are trying to achieve Density Independent Design in javaFX.(say if window width of 200px assume it takes 20cm in 88dpi. and if same 200px window size application run in different PPI it should occupy only 20cm). but…
mcd
  • 1,434
  • 15
  • 31
3
votes
2 answers

How to get width and height of resized custom view , before it is drawn

In my custom View .xml , i have defined width and height as w = 600dp , h = 700dp. Now i know getMeasuredHeight() / getMeasuredWidth() give values of width and height after view is drawn and they may differ from what i've given in .xml file , is…
3
votes
1 answer

Wrap content vs setting dp

This DP measure is pretty confusing, I'm trying to learn when should I use wrap_content and when should I set the height, when using ImageView. My current issue is that I'm using wrap content on 3 images (and yes I have different resources for each…
Christopher Francisco
  • 15,672
  • 28
  • 94
  • 206
3
votes
1 answer

How to build windows store app for device independent pixel (DIP)

i am building windows store app. I am using windows 8 and WPF with visual studio .net 2012. UI of this application should be scalable to different screens. I have created a page where the controls (buttons, images, texts) fits correctly when running…
3
votes
1 answer

How does android handle px vs dp in the browser?

Everything I've found so far on Android's handling of px and dp seems to be regarding native android applications. How does Android handle websites using px in their CSS? Does it automatically convert it to the appropriate dp size?
Eric
  • 2,004
  • 6
  • 23
  • 33