Java Code Examples for android.util.TypedValue#complexToFloat()
The following examples show how to use
android.util.TypedValue#complexToFloat() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Rotate3dAnimation.java From pe-protector-moe with GNU General Public License v3.0 | 5 votes |
Description parseValue(TypedValue value) { Description d = new Description(); if (value == null) { d.type = ABSOLUTE; d.value = 0; } else { if (value.type == TypedValue.TYPE_FRACTION) { d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) == TypedValue.COMPLEX_UNIT_FRACTION_PARENT ? RELATIVE_TO_PARENT : RELATIVE_TO_SELF; d.value = TypedValue.complexToFloat(value.data); return d; } else if (value.type == TypedValue.TYPE_FLOAT) { d.type = ABSOLUTE; d.value = value.getFloat(); return d; } else if (value.type >= TypedValue.TYPE_FIRST_INT && value.type <= TypedValue.TYPE_LAST_INT) { d.type = ABSOLUTE; d.value = value.data; return d; } } d.type = ABSOLUTE; d.value = 0.0f; return d; }
Example 2
Source File: Animation.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Size descriptions can appear inthree forms: * <ol> * <li>An absolute size. This is represented by a number.</li> * <li>A size relative to the size of the object being animated. This * is represented by a number followed by "%".</li> * * <li>A size relative to the size of the parent of object being * animated. This is represented by a number followed by "%p".</li> * </ol> * @param value The typed value to parse * @return The parsed version of the description */ static Description parseValue(TypedValue value) { Description d = new Description(); if (value == null) { d.type = ABSOLUTE; d.value = 0; } else { if (value.type == TypedValue.TYPE_FRACTION) { d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) == TypedValue.COMPLEX_UNIT_FRACTION_PARENT ? RELATIVE_TO_PARENT : RELATIVE_TO_SELF; d.value = TypedValue.complexToFloat(value.data); return d; } else if (value.type == TypedValue.TYPE_FLOAT) { d.type = ABSOLUTE; d.value = value.getFloat(); return d; } else if (value.type >= TypedValue.TYPE_FIRST_INT && value.type <= TypedValue.TYPE_LAST_INT) { d.type = ABSOLUTE; d.value = value.data; return d; } } d.type = ABSOLUTE; d.value = 0.0f; return d; }
Example 3
Source File: Rotate3dAnimation.java From KAlertDialog with Apache License 2.0 | 5 votes |
private Description parseValue(TypedValue value) { Description d = new Description(); if (value == null) { d.type = ABSOLUTE; d.value = 0; } else { if (value.type == TypedValue.TYPE_FRACTION) { d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) == TypedValue.COMPLEX_UNIT_FRACTION_PARENT ? RELATIVE_TO_PARENT : RELATIVE_TO_SELF; d.value = TypedValue.complexToFloat(value.data); return d; } else if (value.type == TypedValue.TYPE_FLOAT) { d.type = ABSOLUTE; d.value = value.getFloat(); return d; } else if (value.type >= TypedValue.TYPE_FIRST_INT && value.type <= TypedValue.TYPE_LAST_INT) { d.type = ABSOLUTE; d.value = value.data; return d; } } d.type = ABSOLUTE; d.value = 0.0f; return d; }
Example 4
Source File: ScreenUtils.java From XKnife-Android with Apache License 2.0 | 5 votes |
/** * 获得dimen.xml中原始的值 * * @param context the context * @param id the id * @return xml def */ public static int getXmlDef(Context context, int id) { synchronized (mTmpValue) { TypedValue value = mTmpValue; context.getResources().getValue(id, value, true); return (int) TypedValue.complexToFloat(value.data); } }
Example 5
Source File: HorizontalCalendarView.java From Horizontal-Calendar with Apache License 2.0 | 5 votes |
/** * get the raw value from a complex value ( Ex: complex = 14sp, returns 14) */ private float getRawSizeValue(TypedArray a, int index, float defValue) { TypedValue outValue = new TypedValue(); boolean result = a.getValue(index, outValue); if (!result) { return defValue; } return TypedValue.complexToFloat(outValue.data); }
Example 6
Source File: Rotate3dAnimation.java From HaiNaBaiChuan with Apache License 2.0 | 5 votes |
Description parseValue(TypedValue value) { Description d = new Description(); if (value == null) { d.type = ABSOLUTE; d.value = 0; } else { if (value.type == TypedValue.TYPE_FRACTION) { d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) == TypedValue.COMPLEX_UNIT_FRACTION_PARENT ? RELATIVE_TO_PARENT : RELATIVE_TO_SELF; d.value = TypedValue.complexToFloat(value.data); return d; } else if (value.type == TypedValue.TYPE_FLOAT) { d.type = ABSOLUTE; d.value = value.getFloat(); return d; } else if (value.type >= TypedValue.TYPE_FIRST_INT && value.type <= TypedValue.TYPE_LAST_INT) { d.type = ABSOLUTE; d.value = value.data; return d; } } d.type = ABSOLUTE; d.value = 0.0f; return d; }
Example 7
Source File: ViewUtils.java From Android-Next with Apache License 2.0 | 5 votes |
public static int getActionBarHeightInDp(Context context) { int actionBarHeight = 0; TypedValue tv = new TypedValue(); final DisplayMetrics dm = context.getResources().getDisplayMetrics(); if (Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) actionBarHeight = (int) TypedValue.complexToFloat(tv.data); } else { tv.data = 48; actionBarHeight = (int) TypedValue.complexToFloat(tv.data); } return actionBarHeight; }
Example 8
Source File: ViewUtils.java From Android-Next with Apache License 2.0 | 4 votes |
/** * 获取资源中的数值,没有经过转换,比如dp,sp等 */ public static int getResourceValue(Context context, int resId) { TypedValue value = mTmpValue; context.getResources().getValue(resId, value, true); return (int) TypedValue.complexToFloat(value.data); }