public class UIUtils
extends java.lang.Object
| Constructor and Description |
|---|
UIUtils() |
| Modifier and Type | Method and Description |
|---|---|
static float |
convertDpToPixel(float dp,
android.content.Context context)
This method converts dp unit to equivalent pixels, depending on device density.
|
static float |
convertPixelsToDp(float px,
android.content.Context context)
This method converts device specific pixels to density independent pixels.
|
static int |
getThemeAttributeDimensionSize(android.content.Context context,
int attr)
Returns the size in pixels of an attribute dimension
|
static int |
getThemeColor(android.content.Context ctx,
int attr) |
static int |
getThemeColorFromAttrOrRes(android.content.Context ctx,
int attr,
int res)
helper method to get the color by attr (which is defined in the style) or by resource.
|
static void |
setBackground(android.view.View v,
android.graphics.drawable.Drawable d)
helper method to set the background depending on the android version
|
static void |
setBackground(android.view.View v,
int drawableRes)
helper method to set the background depending on the android version
|
public static int getThemeColor(android.content.Context ctx,
int attr)
public static int getThemeColorFromAttrOrRes(android.content.Context ctx,
int attr,
int res)
ctx - attr - res - public static void setBackground(android.view.View v,
android.graphics.drawable.Drawable d)
v - d - public static void setBackground(android.view.View v,
int drawableRes)
v - drawableRes - public static int getThemeAttributeDimensionSize(android.content.Context context,
int attr)
context - the context to get the resources fromattr - is the attribute dimension we want to know the size frompublic static float convertDpToPixel(float dp,
android.content.Context context)
dp - A value in dp (density independent pixels) unit. Which we need to convert into pixelscontext - Context to get resources and device specific display metricspublic static float convertPixelsToDp(float px,
android.content.Context context)
px - A value in px (pixels) unit. Which we need to convert into dbcontext - Context to get resources and device specific display metrics