当前位置: 首页>>代码示例>>Java>>正文


Java TypedValue.TYPE_FRACTION属性代码示例

本文整理汇总了Java中android.util.TypedValue.TYPE_FRACTION属性的典型用法代码示例。如果您正苦于以下问题:Java TypedValue.TYPE_FRACTION属性的具体用法?Java TypedValue.TYPE_FRACTION怎么用?Java TypedValue.TYPE_FRACTION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.util.TypedValue的用法示例。


在下文中一共展示了TypedValue.TYPE_FRACTION属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

@SuppressWarnings("deprecation")
private void init(Context context) {
  // Set min width
  Resources.Theme theme = context.getTheme();
  int resId = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
      ? android.R.attr.windowMinWidthMinor
      : android.R.attr.windowMinWidthMajor;
  TypedValue tv = new TypedValue();
  theme.resolveAttribute(resId, tv, true);
  if (tv.type == TypedValue.TYPE_DIMENSION) {
    DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
    setMinWidthSize((int) tv.getDimension(metrics));
  } else if (tv.type == TypedValue.TYPE_FRACTION) {
    setMiniWidthPercent(tv.getFraction(1, 1));
  }

  // Set background
  Drawable drawable = AttrResources.getAttrDrawable(context, android.R.attr.windowBackground);
  setBackgroundDrawable(drawable);

  // Set elevation
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    float elevation = AttrResources.getAttrDimension(context, android.R.attr.windowElevation);
    setElevation(elevation);
  }
}
 
开发者ID:seven332,项目名称:Stage,代码行数:26,代码来源:DialogContentView.java

示例2: parseValue

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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:Rotate3dAnimation.java

示例3: factory

public ResScalarValue factory(int type, int value, String rawValue) throws IOException {
	switch (type) {
	case TypedValue.TYPE_NULL:
		return new ResReferenceValue(mPackage, 0, null);
	case TypedValue.TYPE_REFERENCE:
		return newReference(value, rawValue);
	case TypedValue.TYPE_ATTRIBUTE:
		return newReference(value, rawValue, true);
	case TypedValue.TYPE_STRING:
		return new ResStringValue(rawValue, value);
	case TypedValue.TYPE_FLOAT:
		return new ResFloatValue(Float.intBitsToFloat(value), value, rawValue);
	case TypedValue.TYPE_DIMENSION:
		return new ResDimenValue(value, rawValue);
	case TypedValue.TYPE_FRACTION:
		return new ResFractionValue(value, rawValue);
	case TypedValue.TYPE_INT_BOOLEAN:
		return new ResBoolValue(value != 0, value, rawValue);
	case 0x07:
		return newReference(value, rawValue);
	}

	if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) {
		return new ResColorValue(value, rawValue);
	}
	if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
		return new ResIntValue(value, rawValue, type);
	}

	throw new IOException("Invalid value type: " + type);
}
 
开发者ID:seaase,项目名称:ArscEditor,代码行数:31,代码来源:ResValueFactory.java

示例4: setGradientRadius

void setGradientRadius(Context context, AttributeSet attrs, GradientDrawable drawable, int gradientType) throws XmlPullParserException {
    TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{android.R.attr.gradientRadius});
    TypedValue value = a.peekValue(0);
    if (value != null) {
        boolean radiusRel = value.type == TypedValue.TYPE_FRACTION;
        drawable.setGradientRadius(radiusRel ? value.getFraction(1.0f, 1.0f) : value.getFloat());
    } else if (gradientType == GradientDrawable.RADIAL_GRADIENT) {
        throw new XmlPullParserException(
                "<gradient> tag requires 'gradientRadius' "
                        + "attribute with radial type");
    }
    a.recycle();
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:13,代码来源:GradientDrawableUtils.java

示例5: getAttrFloatOrFraction

float getAttrFloatOrFraction(Context context, AttributeSet attrs, int attr, float defaultValue, float base, float pbase) {
    TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
    TypedValue tv = a.peekValue(0);
    float v = defaultValue;
    if (tv != null) {
        boolean isFraction = tv.type == TypedValue.TYPE_FRACTION;
        v = isFraction ? tv.getFraction(base, pbase) : tv.getFloat();
    }
    a.recycle();
    return v;
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:11,代码来源:GradientDrawableUtils.java

示例6: getAttributeValue

private static String getAttributeValue(XmlResourceParser parser, int index) {
    int type = parser.getAttributeValueType(index);
    int data = parser.getAttributeValueData(index);
    if (type == TypedValue.TYPE_STRING) {
        return parser.getAttributeValue(index);
    }
    if (type == TypedValue.TYPE_ATTRIBUTE) {
        return String.format("?%s%08X", getPackage(data), data);
    }
    if (type == TypedValue.TYPE_REFERENCE) {
        return String.format("@%s%08X", getPackage(data), data);
    }
    if (type == TypedValue.TYPE_FLOAT) {
        return String.valueOf(Float.intBitsToFloat(data));
    }
    if (type == TypedValue.TYPE_INT_HEX) {
        return String.format("0x%08X", data);
    }
    if (type == TypedValue.TYPE_INT_BOOLEAN) {
        return data != 0 ? "true" : "false";
    }
    if (type == TypedValue.TYPE_DIMENSION) {
        return Float.toString(complexToFloat(data)) + DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
    }
    if (type == TypedValue.TYPE_FRACTION) {
        return Float.toString(complexToFloat(data)) + FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
    }
    if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) {
        return String.format("#%08X", data);
    }
    if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
        return String.valueOf(data);
    }
    return String.format("<0x%X, type 0x%02X>", data, type);
}
 
开发者ID:LiangMaYong,项目名称:android-apkbox,代码行数:35,代码来源:ApkManifestReader.java

示例7: getAttributeValue

public static String getAttributeValue(AXmlResourceParser parser,int index) {
	int type=parser.getAttributeValueType(index);
	int data=parser.getAttributeValueData(index);
	if (type==TypedValue.TYPE_STRING) {
		return parser.getAttributeValue(index);
	}
	if (type==TypedValue.TYPE_ATTRIBUTE) {
		return String.format("?%s%08X",getPackage(data),data);
	}
	if (type==TypedValue.TYPE_REFERENCE) {
		return String.format("@%s%08X",getPackage(data),data);
	}
	if (type==TypedValue.TYPE_FLOAT) {
		return String.valueOf(Float.intBitsToFloat(data));
	}
	if (type==TypedValue.TYPE_INT_HEX) {
		return String.format("0x%08X",data);
	}
	if (type==TypedValue.TYPE_INT_BOOLEAN) {
		return data!=0?"true":"false";
	}
	if (type==TypedValue.TYPE_DIMENSION) {
		return Float.toString(complexToFloat(data))+
			DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
	}
	if (type==TypedValue.TYPE_FRACTION) {
		return Float.toString(complexToFloat(data))+
			FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
	}
	if (type>=TypedValue.TYPE_FIRST_COLOR_INT && type<=TypedValue.TYPE_LAST_COLOR_INT) {
		return String.format("#%08X",data);
	}
	if (type>=TypedValue.TYPE_FIRST_INT && type<=TypedValue.TYPE_LAST_INT) {
		return String.valueOf(data);
	}
	return String.format("<0x%X, type 0x%02X>",data,type);
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:37,代码来源:AXMLPrinter.java

示例8: isFractionValue

public static boolean isFractionValue(final TypedValue v) {
    return v.type == TypedValue.TYPE_FRACTION;
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:3,代码来源:ResourceUtils.java

示例9: extractAttributes

private void extractAttributes(@NonNull final Context context, @Nullable final AttributeSet attrs)
{
	if (attrs != null)
	{
		final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.SplitPaneLayout);

		// misc
		this.orientation = array.getInt(R.styleable.SplitPaneLayout_orientation, 0);
		this.splitterSize = array.getDimensionPixelSize(R.styleable.SplitPaneLayout_splitterSize, context.getResources().getDimensionPixelSize(R.dimen.spl_default_splitter_size));
		this.splitterMovable = array.getBoolean(R.styleable.SplitPaneLayout_splitterMovable, true);

		// position
		TypedValue value = array.peekValue(R.styleable.SplitPaneLayout_splitterPosition);
		if (value != null)
		{
			if (value.type == TypedValue.TYPE_DIMENSION)
			{
				this.splitterPosition = array.getDimensionPixelSize(R.styleable.SplitPaneLayout_splitterPosition, Integer.MIN_VALUE);
				this.splitterPositionPercent = -1;
			}
			else if (value.type == TypedValue.TYPE_FRACTION)
			{
				this.splitterPositionPercent = array.getFraction(R.styleable.SplitPaneLayout_splitterPosition, 100, 100, 50) * 0.01f;
				this.splitterPosition = Integer.MIN_VALUE;
			}
		}
		else
		{
			this.splitterPosition = Integer.MIN_VALUE;
			this.splitterPositionPercent = 0.5f;
		}

		// backgrounds
		value = array.peekValue(R.styleable.SplitPaneLayout_splitterBackground);
		if (value != null)
		{
			if (value.type == TypedValue.TYPE_REFERENCE || value.type == TypedValue.TYPE_STRING)
			{
				this.splitterDrawable = array.getDrawable(R.styleable.SplitPaneLayout_splitterBackground);
			}
			else if (value.type == TypedValue.TYPE_INT_COLOR_ARGB8 || value.type == TypedValue.TYPE_INT_COLOR_ARGB4 || value.type == TypedValue.TYPE_INT_COLOR_RGB8 || value.type == TypedValue.TYPE_INT_COLOR_RGB4)
			{
				this.splitterDrawable = new PaintDrawable(array.getColor(R.styleable.SplitPaneLayout_splitterBackground, 0xFF000000));
			}
		}
		value = array.peekValue(R.styleable.SplitPaneLayout_splitterDraggingBackground);
		if (value != null)
		{
			if (value.type == TypedValue.TYPE_REFERENCE || value.type == TypedValue.TYPE_STRING)
			{
				this.splitterDraggingDrawable = array.getDrawable(R.styleable.SplitPaneLayout_splitterDraggingBackground);
			}
			else if (value.type == TypedValue.TYPE_INT_COLOR_ARGB8 || value.type == TypedValue.TYPE_INT_COLOR_ARGB4 || value.type == TypedValue.TYPE_INT_COLOR_RGB8 || value.type == TypedValue.TYPE_INT_COLOR_RGB4)
			{
				this.splitterDraggingDrawable = new PaintDrawable(array.getColor(R.styleable.SplitPaneLayout_splitterDraggingBackground, SPLITTER_DRAG_COLOR));
			}
		}
		else
		{
			this.splitterDraggingDrawable = new PaintDrawable(SPLITTER_DRAG_COLOR);
		}
		array.recycle();
	}
}
 
开发者ID:1313ou,项目名称:TreebolicLib,代码行数:64,代码来源:SplitPaneLayout.java


注:本文中的android.util.TypedValue.TYPE_FRACTION属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。