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


Java View.LAYER_TYPE_SOFTWARE属性代码示例

本文整理汇总了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();
    }
}
 
开发者ID:garretyoder,项目名称:Cluttr,代码行数:24,代码来源:CropOverlayView.java

示例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);
    }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:23,代码来源:FloatingActionButtonImpl.java

示例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();
  }
}
 
开发者ID:prashantsaini1,项目名称:android-titanium-imagecropper,代码行数:22,代码来源:CropOverlayView.java

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

示例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();
}
 
开发者ID:android-notes,项目名称:shadow,代码行数:55,代码来源:ShadowHelper.java

示例6: RevealFinishedIceCreamSandwich

RevealFinishedIceCreamSandwich(RevealAnimator target) {
    super(target);

    mLayerType = ((View) target).getLayerType();
    mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
 
开发者ID:SimonCherryGZ,项目名称:JewelryUI,代码行数:6,代码来源:RevealAnimator.java


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