Java Code Examples for android.view.View.getLayerType()

The following are Jave code examples for showing how to use getLayerType() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: GitHub   File: InfiniteCycleManager.java   Source Code and License Vote up 6 votes
private void disableHardwareLayers() {
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) return;
    for (int i = 0; i < mViewPageable.getChildCount(); i++) {
        final View child = mViewPageable.getChildAt(i);
        if (child.getLayerType() != View.LAYER_TYPE_NONE)
            child.setLayerType(View.LAYER_TYPE_NONE, null);
    }
}
 
Example 2
Project: JewelryUI   File: JazzyViewPager.java   Source Code and License Vote up 6 votes
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void manageLayer(View v, boolean enableHardware) {
	if (!API_11) return;
	int layerType = enableHardware ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;
	if (layerType != v.getLayerType())
		v.setLayerType(layerType, null);
}
 
Example 3
Project: JewelryUI   File: JazzyViewPager.java   Source Code and License Vote up 6 votes
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void disableHardwareLayer() {
	if (!API_11) return;
	View v;
	for (int i = 0; i < getChildCount(); i++) {
		v = getChildAt(i);
		if (v.getLayerType() != View.LAYER_TYPE_NONE)
			v.setLayerType(View.LAYER_TYPE_NONE, null);
	}
}
 
Example 4
Project: letv   File: JazzyViewPager.java   Source Code and License Vote up 6 votes
@TargetApi(11)
private void manageLayer(View v, boolean enableHardware) {
    if (API_11) {
        int layerType = enableHardware ? 2 : 0;
        if (layerType != v.getLayerType()) {
            v.setLayerType(layerType, null);
        }
    }
}
 
Example 5
Project: letv   File: JazzyViewPager.java   Source Code and License Vote up 6 votes
@TargetApi(11)
private void disableHardwareLayer() {
    if (API_11) {
        for (int i = 0; i < getChildCount(); i++) {
            View v = getChildAt(i);
            if (v.getLayerType() != 0) {
                v.setLayerType(0, null);
            }
        }
    }
}
 
Example 6
Project: JazzyViewPager   File: JazzyViewPager.java   Source Code and License Vote up 6 votes
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void manageLayer(View v, boolean enableHardware) {
	if (!API_11) return;
	int layerType = enableHardware ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;
	if (layerType != v.getLayerType())
		v.setLayerType(layerType, null);
}
 
Example 7
Project: JazzyViewPager   File: JazzyViewPager.java   Source Code and License Vote up 6 votes
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void disableHardwareLayer() {
	if (!API_11) return;
	View v;
	for (int i = 0; i < getChildCount(); i++) {
		v = getChildAt(i);
		if (v.getLayerType() != View.LAYER_TYPE_NONE)
			v.setLayerType(View.LAYER_TYPE_NONE, null);
	}
}
 
Example 8
Project: CircularRevealCompat   File: ViewAnimationCompatUtils.java   Source Code and License Vote up 6 votes
public static Animator createCircularReveal(View revealView, int centerX, int centerY,
                                            float startRadius, float endRadius, int layerType) {
    Animator animator = CircularRevealAnimator.ofRevealCircle(revealView, centerX, centerY,
            startRadius, endRadius);
    if (layerType != revealView.getLayerType()) {
        animator.addListener(new CircularRevealAnimator.ChangeViewLayerTypeListener(revealView, layerType));
    }
    return animator;
}
 
Example 9
Project: CircularRevealCompat   File: ViewAnimationCompatUtils.java   Source Code and License Vote up 6 votes
public static Animator createCircularReveal(View revealView, float startCenterX, float startCenterY, float startRadius,
                                            float endCenterX, float endCenterY, float endRadius, int layerType) {
    Animator animator = CircularRevealAnimator.ofRevealCircle(revealView, startCenterX, startCenterY, startRadius,
            endCenterX, endCenterY, endRadius);
    if (layerType != revealView.getLayerType()) {
        animator.addListener(new CircularRevealAnimator.ChangeViewLayerTypeListener(revealView, layerType));
    }
    return animator;
}
 
Example 10
Project: GitHub   File: InfiniteCycleManager.java   Source Code and License Vote up 5 votes
private void enableHardwareLayer(final View v) {
    final int layerType = Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT ?
            View.LAYER_TYPE_NONE : View.LAYER_TYPE_HARDWARE;
    if (v.getLayerType() != layerType) v.setLayerType(layerType, null);
}
 
Example 11
Project: letv   File: ViewCompatHC.java   Source Code and License Vote up 5 votes
public static int getLayerType(View view) {
    return view.getLayerType();
}
 
Example 12
Project: shadow   File: ShadowHelper.java   Source Code and License Vote up 5 votes
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();
}
 
Example 13
Project: boohee_v5.6   File: ViewCompatHC.java   Source Code and License Vote up 5 votes
public static int getLayerType(View view) {
    return view.getLayerType();
}
 
Example 14
Project: CircularRevealCompat   File: CircularRevealAnimator.java   Source Code and License Vote up 5 votes
ChangeViewLayerTypeListener(View clipView, int layerType) {
    this.clipView = clipView;
    this.newLayerType = layerType;
    this.originalLayerType = clipView.getLayerType();
}