Class Overview
Utility class to convert DP to Pixels
These methods use the density given by Android, which is :
- 0.75 on a ldpi screen
- 1 on an mdpi screen
- 1.5 on an hdpi screen
- 2 on an xhdpi screen
So with theses methods, we take into account the logical density given by
Android, but not the real density of the screen.
Summary
Public Methods |
static
int
|
toDP(int pixels)
This methods converts pixels into dp units, according to the logical range's
density.
|
static
int
|
toPixels(int dp)
This methods converts dp into pixel units, according to the logical range's
density.
|
[Expand]
Inherited Methods |
From class
java.lang.Object
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
final
Class<?>
|
getClass()
Returns the runtime class of an object.
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeout, int nanos)
Causes current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or some other
thread interrupts the current thread, or a certain amount of real time has
elapsed.
|
final
void
|
wait(long timeout)
Causes current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a specified
amount of time has elapsed.
|
final
void
|
wait()
Causes current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
|
Public Methods
public
static
int
toDP
(int pixels)
This methods converts pixels into dp units, according to the logical range's
density.
Parameters
pixels |
the pixels to convert |
Returns
- the dp units corresponding to the given
pixels
value
public
static
int
toPixels
(int dp)
This methods converts dp into pixel units, according to the logical range's
density.
Returns
- the pixel units corresponding to the given
dp
value