本文整理匯總了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;
}