本文整理汇总了Java中android.view.View.LAYER_TYPE_SOFTWARE属性的典型用法代码示例。如果您正苦于以下问题:Java View.LAYER_TYPE_SOFTWARE属性的具体用法?Java View.LAYER_TYPE_SOFTWARE怎么用?Java View.LAYER_TYPE_SOFTWARE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.View
的用法示例。
在下文中一共展示了View.LAYER_TYPE_SOFTWARE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCropShape
/**
* The shape of the cropping area - rectangle/circular.
*/
public void setCropShape(CropImageView.CropShape cropShape) {
if (mCropShape != cropShape) {
mCropShape = cropShape;
if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= 17) {
if (mCropShape == CropImageView.CropShape.OVAL) {
mOriginalLayerType = getLayerType();
if (mOriginalLayerType != View.LAYER_TYPE_SOFTWARE) {
// TURN off hardware acceleration
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
} else {
mOriginalLayerType = null;
}
} else if (mOriginalLayerType != null) {
// return hardware acceleration back
setLayerType(mOriginalLayerType, null);
mOriginalLayerType = null;
}
}
invalidate();
}
}
示例2: updateFromViewRotation
private void updateFromViewRotation() {
if (Build.VERSION.SDK_INT == 19) {
// KitKat seems to have an issue with views which are rotated with angles which are
// not divisible by 90. Worked around by moving to software rendering in these cases.
if ((mRotation % 90) != 0) {
if (mView.getLayerType() != View.LAYER_TYPE_SOFTWARE) {
mView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
} else {
if (mView.getLayerType() != View.LAYER_TYPE_NONE) {
mView.setLayerType(View.LAYER_TYPE_NONE, null);
}
}
}
// Offset any View rotation
if (mShadowDrawable != null) {
mShadowDrawable.setRotation(-mRotation);
}
if (mBorderDrawable != null) {
mBorderDrawable.setRotation(-mRotation);
}
}
示例3: setCropShape
/** The shape of the cropping area - rectangle/circular. */
public void setCropShape(CropImageView.CropShape cropShape) {
if (mCropShape != cropShape) {
mCropShape = cropShape;
if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= 17) {
if (mCropShape == CropImageView.CropShape.OVAL) {
mOriginalLayerType = getLayerType();
if (mOriginalLayerType != View.LAYER_TYPE_SOFTWARE) {
// TURN off hardware acceleration
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
} else {
mOriginalLayerType = null;
}
} else if (mOriginalLayerType != null) {
// return hardware acceleration back
setLayerType(mOriginalLayerType, null);
mOriginalLayerType = null;
}
}
invalidate();
}
}
示例4: fixCanvasScalingWhenHardwareAccelerated
private static void fixCanvasScalingWhenHardwareAccelerated(ProgressBar pb) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB &&
Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
// Canvas scaling when hardware accelerated results in artifacts on older API levels, so
// we need to use software rendering
if (pb.isHardwareAccelerated() && pb.getLayerType() != View.LAYER_TYPE_SOFTWARE) {
pb.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}
}
示例5: draw
public static void draw(Canvas canvas, View view, Config config) {
Check.ifNull(canvas);
Check.ifNull(view);
Check.ifNull(config);
View parent = (View) view.getParent();
if (parent.getLayerType() != View.LAYER_TYPE_SOFTWARE) {
parent.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
return;
}
int count = canvas.save();
int viewHeight = view.getHeight();
int viewWidth = view.getWidth();
float padding = config.radius * RATIO;
int xOffset = config.xOffset;
int yOffset = config.yOffset;
initPath(viewWidth, viewHeight, config);
try {
/*
clipPath时部分4.0 手机会抛出如下异常, 比如
OPPO X907 cpu高通骁龙Snapdragon MSM8260 内存1GB 系统版本4.0.3 分辨率800x480
FATAL EXCEPTION:main
java.lang.UnsupportedOperationException
at android.view.GLES20Canvas.clipPath(GLES20Canvas.java:429)
*/
canvas.clipPath(sPath, Region.Op.REPLACE);
} catch (Exception e) {
Log.e("shadow", "不支持clipPath");
e.printStackTrace();
canvas.restoreToCount(count);
config.recycle();
return;
}
sRectF.left = xOffset - padding;
sRectF.top = yOffset - padding;
sRectF.right = viewWidth + xOffset + padding;
sRectF.bottom = viewHeight + yOffset + padding;
canvas.clipRect(sRectF, Region.Op.REVERSE_DIFFERENCE);
canvas.translate(xOffset, yOffset);
sPaint.setColor(config.color);
sPaint.setMaskFilter(new BlurMaskFilter(config.radius, BlurMaskFilter.Blur.NORMAL));
canvas.drawPath(sPath, sPaint);
canvas.restoreToCount(count);
config.recycle();
}
示例6: RevealFinishedIceCreamSandwich
RevealFinishedIceCreamSandwich(RevealAnimator target) {
super(target);
mLayerType = ((View) target).getLayerType();
mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}