density-independent-pixel Questions

13

I need to code the layout of the android widgets using dip/dp (in java files). At runtime if I code, int pixel=this.getWindowManager().getDefaultDisplay().getWidth(); this return the screen width...
Ethical asked 24/6, 2011 at 9:6

7

Solved

I have known the difference among DP, SP and PX. And after searching this topic, I found nothing satisfying me completely. Maybe this post is a duplicate, but I still want to know what is the formu...
Reliquary asked 16/4, 2015 at 3:47

21

Solved

I am trying to calculate a variable amount of pixels to density independent pixels and vice-versa. This formula (px to dp): dp = (int)(px / (displayMetrics.densityDpi / 160)); does not work on sm...
Reinhart asked 29/11, 2011 at 10:38

2

Solved

I want to set the height of view in pixels not in dp. `Box(modifier = Modifier.height(100.dp))` In this example height of the box is set to 100 dp and modifier function accepts only dp. How to se...

6

Solved

I was reading dp, dip, px, sp measurements, but I still have some questions about dp/dpi vs ppi vs px vs inch. I am not able to compare them... is an inch the largest? They say 160 dpi means 160 ...

7

Solved

Does setWidth(int pixels) use device independent pixel or physical pixel as unit? For example, does setWidth(100) set the a view's width to 100 dips or 100 pxs? Thanks.

4

Solved

I want to convert dp to px in my C# code in xamarin.android, but all I could find were java codes in android studio that have some problems in xamarin. I tried to use equivalent like using Resource...

4

Solved

val margin = 8 ConstraintSet().apply { connect(anId, ConstraintSet.START, anotherId, ConstraintSet.START, margin) } Is margin applied as pixels or density-dependent pixels? Various articles sca...
Phlogopite asked 22/5, 2019 at 21:16

4

Solved

I had written method to get the pixels from dip but it is not working. It give me runtime error. Actually I was running this method in separate class and initialized in my Activity class Board boar...
Conwell asked 6/12, 2011 at 11:28

4

im throughoutly confused by dips on Android. I understand from the reference that the base for dp values is 160. So, shouldn't 80dp in width equals a view with a width of 50% of the screen ? On my...
Bounty asked 16/1, 2011 at 18:48

3

Solved

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 me...
Raulrausch asked 30/1, 2015 at 16:0

2

Solved

Assume we have two android devices with the same screen dimensions, but with different resolutions. Is the following true or not: if dp unit is used to set the sizes of all views, then both screens...
Farleigh asked 28/6, 2015 at 14:6

4

Solved

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.
Luger asked 1/10, 2013 at 10:39

1

Solved

Since dip stands for "device independent pixels", is there a standard number of dip for every android device out there? Example: if a hdpi device has X dp/width and Y dp/height, does a ldpi device...
Electro asked 21/8, 2014 at 13:26

4

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 ha...
Araucania asked 13/12, 2013 at 16:40

2

I have two images I want to display within my app. The first image is to be full screen (as a background for the app). I have read the 'Supporting Multiple Screens' article on developers.android.co...
Rakel asked 13/3, 2013 at 0:30

2

Solved

Recently I discovered WPF supports different measurement units in XAML. Besides default DIPs, there is also support for pixels, inches and centimeters (as far as I know). This allows designer to wr...
Gulgee asked 29/2, 2012 at 18:33

1

Solved

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 pixel...
Monopolize asked 7/6, 2011 at 17:10

3

Solved

I've done some research on building layouts that work for multiple screen sizes and I'm looking for some clarification. Is it common practice to just make a separate layout file for each of the th...
Anatto asked 5/12, 2010 at 20:5

4

I found that it is possible to set dimensions of my interface elements in XML layouts using DIPs as in following fragment: android:layout_width="10dip" But all Java interface takes integer as a...
Fontainebleau asked 10/2, 2010 at 17:22
1

© 2022 - 2024 — McMap. All rights reserved.