public class UIUtils
extends java.lang.Object
| Constructor and Description |
|---|
UIUtils() |
| Modifier and Type | Method and Description |
|---|---|
static int |
adjustAlpha(int color,
int alpha)
adjusts the alpha of a color
|
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 |
getActionBarHeight(android.content.Context context)
helper to calculate the actionBar height
|
static android.graphics.drawable.StateListDrawable |
getIconStateList(android.graphics.drawable.Drawable icon,
android.graphics.drawable.Drawable selectedIcon)
helper to create a stateListDrawable for the icon
|
static int |
getNavigationBarHeight(android.content.Context context)
helper to calculate the navigationBar height
|
static int |
getScreenHeight(android.content.Context context)
Returns the screen height in pixels
|
static int |
getScreenWidth(android.content.Context context)
Returns the screen width in pixels
|
static android.graphics.drawable.Drawable |
getSelectableBackground(android.content.Context ctx)
helper to get the system default selectable background
|
static android.graphics.drawable.StateListDrawable |
getSelectableBackground(android.content.Context ctx,
int selected_color,
boolean animate)
helper to get the system default selectable background inclusive an active state
|
static int |
getSelectableBackgroundRes(android.content.Context ctx)
helper to get the system default selectable background res
|
static android.graphics.drawable.StateListDrawable |
getSelectablePressedBackground(android.content.Context ctx,
int selected_color,
int pressed_alpha,
boolean animate)
helper to get the system default selectable background inclusive an active and pressed state
|
static int |
getStatusBarHeight(android.content.Context context)
helper to calculate the statusBar height
|
static int |
getStatusBarHeight(android.content.Context context,
boolean force)
helper to calculate the statusBar height
|
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)
a helper method to get the color from an attribute
|
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)
Deprecated.
|
static void |
setBackground(android.view.View v,
int drawableRes)
helper method to set the background depending on the android version
|
static void |
setFlag(android.app.Activity activity,
int bits,
boolean on)
helper method to activate or deactivate a specific flag
|
static void |
setTranslucentNavigationFlag(android.app.Activity activity,
boolean on)
helper method to set the TranslucentNavigationFlag
|
static void |
setTranslucentStatusFlag(android.app.Activity activity,
boolean on)
helper method to set the TranslucentStatusFlag
|
public static int getThemeColor(android.content.Context ctx,
int attr)
ctx - attr - public static int getThemeColorFromAttrOrRes(android.content.Context ctx,
int attr,
int res)
ctx - attr - res - @Deprecated
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 int getNavigationBarHeight(android.content.Context context)
context - public static int getActionBarHeight(android.content.Context context)
context - public static int getStatusBarHeight(android.content.Context context)
context - public static int getStatusBarHeight(android.content.Context context,
boolean force)
context - force - pass true to get the height even if the device has no translucent statusBarpublic 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 metricspublic static void setTranslucentStatusFlag(android.app.Activity activity,
boolean on)
on - public static void setTranslucentNavigationFlag(android.app.Activity activity,
boolean on)
on - public static void setFlag(android.app.Activity activity,
int bits,
boolean on)
bits - on - public static android.graphics.drawable.StateListDrawable getIconStateList(android.graphics.drawable.Drawable icon,
android.graphics.drawable.Drawable selectedIcon)
icon - selectedIcon - public static android.graphics.drawable.StateListDrawable getSelectableBackground(android.content.Context ctx,
int selected_color,
boolean animate)
ctx - the contextselected_color - the selected coloranimate - true if you want to fade over the states (only animates if API newer than Build.VERSION_CODES.HONEYCOMB)public static android.graphics.drawable.StateListDrawable getSelectablePressedBackground(android.content.Context ctx,
int selected_color,
int pressed_alpha,
boolean animate)
ctx - the contextselected_color - the selected colorpressed_alpha - 0-255animate - true if you want to fade over the states (only animates if API newer than Build.VERSION_CODES.HONEYCOMB)public static int adjustAlpha(int color,
int alpha)
color - the coloralpha - the alpha value we want to set 0-255public static int getSelectableBackgroundRes(android.content.Context ctx)
ctx - public static android.graphics.drawable.Drawable getSelectableBackground(android.content.Context ctx)
ctx - public static int getScreenWidth(android.content.Context context)
context - is the context to get the resourcespublic static int getScreenHeight(android.content.Context context)
context - is the context to get the resources