Package io.anyline2.util
Class DimensUtil
-
- All Implemented Interfaces:
public class DimensUtil
A helper class with methods to deal with dimensions and orientation.
-
-
Constructor Summary
Constructors Constructor Description DimensUtil()
-
Method Summary
Modifier and Type Method Description static int
getPixFromDp(Context context, int dp)
Get the pixels for dp rounded to int. static int
dpToPx(Context context, float dp)
static int
getDpFromPix(Context context, int pix)
Get the dp for given pixels rounded to int. static int
getScreenOrientation(Context context)
Get the current screen orientation. static boolean
isOrientationPortrait(Context context)
Returns true if screen orientation is Portrait -
-
Method Detail
-
getPixFromDp
static int getPixFromDp(Context context, int dp)
Get the pixels for dp rounded to int.
- Parameters:
context
- the contextdp
- the dp to convert to pixels- Returns:
the pixels for the given dp
-
getDpFromPix
static int getDpFromPix(Context context, int pix)
Get the dp for given pixels rounded to int.
- Parameters:
context
- the contextpix
- the dp to convert to pixels- Returns:
the dp for the given pixels
-
getScreenOrientation
static int getScreenOrientation(Context context)
Get the current screen orientation.
- Parameters:
context
- the context- Returns:
the current orientation
-
isOrientationPortrait
static boolean isOrientationPortrait(Context context)
Returns true if screen orientation is Portrait
- Parameters:
context
- the context- Returns:
true if screen orientation is Portrait
-
-
-
-