Example usage for android.util TypedValue TypedValue

List of usage examples for android.util TypedValue TypedValue

Introduction

In this page you can find the example usage for android.util TypedValue TypedValue.

Prototype

TypedValue

Source Link

Usage

From source file:Main.java

public static int GetActionBarHeight(Context c) {
    TypedValue tv = new TypedValue();
    if (c.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        int height = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics());
        return height;
    }//from w  w w  .  java 2  s. c o m
    return 0;
}

From source file:Main.java

static int getActionBarHeight(Context context) {
    TypedValue tv = new TypedValue();
    if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        int actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,
                context.getResources().getDisplayMetrics());

        return actionBarHeight;
    }//from w w w . j ava  2  s.  c om

    return 0;
}

From source file:Main.java

public static int getActionBarHeight(Activity activity) {
    TypedValue tv = new TypedValue();
    if (activity.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        return TypedValue.complexToDimensionPixelSize(tv.data, activity.getResources().getDisplayMetrics());
    }/*from   w w  w.  j a  v a2  s. co  m*/
    return 0;
}

From source file:Main.java

public static int getEditTextColor(Context ctx) {
    TypedValue tv = new TypedValue();
    boolean found = ctx.getTheme().resolveAttribute(android.R.attr.editTextColor, tv, true);
    if (found) {/*from   w  w  w .  j  a  v  a  2 s  .  co  m*/
        // SDK 11+
        return ctx.getResources().getColor(tv.resourceId);
    } else {
        // SDK < 11
        return ctx.getResources().getColor(android.R.color.primary_text_light);
    }
}

From source file:Main.java

public static int getActionBarHeight(Context context) {
    TypedValue tv = new TypedValue();
    if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        return TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());
    }/*ww  w  .jav  a  2  s  .  c  om*/
    return 0;
}

From source file:Main.java

public static int getActionBarSize(Activity activity) {

    TypedValue tv = new TypedValue();
    if (activity.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        return TypedValue.complexToDimensionPixelSize(tv.data, activity.getResources().getDisplayMetrics());
    }/*from w w w .  j  a v  a2  s. co m*/

    return 0;

}

From source file:Main.java

public static int getThemeTextColorPrimary(Context context) {
    TypedValue textColorPrimary = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.textColorPrimary, textColorPrimary, true);
    return context.getResources().getColor(textColorPrimary.resourceId);
}

From source file:Main.java

public static int getAttributeColor(Context context, int attributeId) {
    TypedValue typedValue = new TypedValue();
    context.getTheme().resolveAttribute(attributeId, typedValue, true);
    return context.getResources().getColor(typedValue.resourceId);
}

From source file:Main.java

public static float getFloatConstant(final Resources res, final int constant) {
    TypedValue outValue = new TypedValue();
    res.getValue(constant, outValue, true);
    return outValue.getFloat();
}

From source file:Main.java

public static int getAccentColor(Context context) {
    TypedValue typedValue = new TypedValue();
    TypedArray typedArray = context.obtainStyledAttributes(typedValue.data, new int[] { 16843829 });
    int accent = typedArray.getColor(0, 0);
    typedArray.recycle();// www.jav a2 s.  co  m
    return accent;
}