Java Code Examples for android.view.View#setLayerType()

The following examples show how to use android.view.View#setLayerType() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: memory-game   File: PopupWonView.java    License: Apache License 2.0 6 votes vote down vote up
private void animateStar(final View view, int delay) {
	ObjectAnimator alpha = ObjectAnimator.ofFloat(view, "alpha", 0, 1f);
	alpha.setDuration(100);
	ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0, 1f);
	ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0, 1f);
	AnimatorSet animatorSet = new AnimatorSet();
	animatorSet.playTogether(alpha, scaleX, scaleY);
	animatorSet.setInterpolator(new BounceInterpolator());
	animatorSet.setStartDelay(delay);
	animatorSet.setDuration(600);
	view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
	animatorSet.start();
	
	mHandler.postDelayed(new Runnable() {
		
		@Override
		public void run() {
			Music.showStar();
		}
	}, delay);
}
 
Example 2
Source Project: DynamicGrid   File: DynamicGridView.java    License: Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private ObjectAnimator createBaseWobble(final View v) {

    if (!isPreLollipop())
        v.setLayerType(LAYER_TYPE_SOFTWARE, null);

    ObjectAnimator animator = new ObjectAnimator();
    animator.setDuration(180);
    animator.setRepeatMode(ValueAnimator.REVERSE);
    animator.setRepeatCount(ValueAnimator.INFINITE);
    animator.setPropertyName("rotation");
    animator.setTarget(v);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            v.setLayerType(LAYER_TYPE_NONE, null);
        }
    });
    return animator;
}
 
Example 3
@SuppressLint("NewApi")
private void setSepiaLayer(View view, boolean isSepiaLayerOn) {
    if (!IS_JBMR2) {
        if (isSepiaLayerOn) {
            if (Build.VERSION.SDK_INT >= 17) {
                view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
                view.setLayerPaint(mSepiaPaint);
            }

        } else {
            if (Build.VERSION.SDK_INT >= 17) {
                view.setLayerPaint(mDefaultPaint);
            }

        }
    }
}
 
Example 4
Source Project: ClockView   File: JazzyViewPager.java    License: Apache License 2.0 5 votes vote down vote up
@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 5
public ShadowCircleTransformation(Context context, View view, float strokeSize) {
  super();
  view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
  this.strokeSize = strokeSize;
  shadowColor = Color.WHITE;
  spaceBetween = .95f;
}
 
Example 6
public void onAnimationStart(Animator animation) {
    getViews(mViews);
    for (View view : mViews) {
        mLayerType.add(view.getLayerType());
        view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }
}
 
Example 7
Source Project: android-FlipView   File: FlipView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Enable a hardware layer for the view.
 * 
 * @param v
 * @param drawWithLayer
 */
private void setDrawWithLayer(View v, boolean drawWithLayer) {
	if (isHardwareAccelerated()) {
		if (v.getLayerType() != LAYER_TYPE_HARDWARE && drawWithLayer) {
			v.setLayerType(LAYER_TYPE_HARDWARE, null);
		} else if (v.getLayerType() != LAYER_TYPE_NONE && !drawWithLayer) {
			v.setLayerType(LAYER_TYPE_NONE, null);
		}
	}
}
 
Example 8
Source Project: ClockView   File: JazzyViewPager.java    License: Apache License 2.0 5 votes vote down vote up
@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 9
Source Project: ShadowDrawable   File: ShadowDrawable.java    License: MIT License 5 votes vote down vote up
/**
 * 为指定View设置带阴影的背景
 * @param view 目标View
 * @param bgColor View背景色
 * @param shapeRadius View的圆角
 * @param shadowColor 阴影的颜色
 * @param shadowRadius 阴影的宽度
 * @param offsetX 阴影水平方向的偏移量
 * @param offsetY 阴影垂直方向的偏移量
 */
public static void setShadowDrawable(View view, int bgColor, int shapeRadius, int shadowColor, int shadowRadius, int offsetX, int offsetY) {
	ShadowDrawable drawable = new ShadowDrawable.Builder()
			.setBgColor(bgColor)
			.setShapeRadius(shapeRadius)
			.setShadowColor(shadowColor)
			.setShadowRadius(shadowRadius)
			.setOffsetX(offsetX)
			.setOffsetY(offsetY)
			.builder();
	view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
	ViewCompat.setBackground(view, drawable);
}
 
Example 10
Source Project: ShadowDrawable   File: ShadowDrawable.java    License: MIT License 5 votes vote down vote up
/**
 * 为指定View设置指定形状并带阴影的背景
 * @param view 目标View
 * @param shape View的形状 取值可为:GradientDrawable.RECTANGLE, GradientDrawable.OVAL, GradientDrawable.RING
 * @param bgColor View背景色
 * @param shapeRadius View的圆角
 * @param shadowColor 阴影的颜色
 * @param shadowRadius 阴影的宽度
 * @param offsetX 阴影水平方向的偏移量
 * @param offsetY 阴影垂直方向的偏移量
 */
public static void setShadowDrawable(View view, int shape, int bgColor, int shapeRadius, int shadowColor, int shadowRadius, int offsetX, int offsetY) {
	ShadowDrawable drawable = new ShadowDrawable.Builder()
			.setShape(shape)
			.setBgColor(bgColor)
			.setShapeRadius(shapeRadius)
			.setShadowColor(shadowColor)
			.setShadowRadius(shadowRadius)
			.setOffsetX(offsetX)
			.setOffsetY(offsetY)
			.builder();
	view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
	ViewCompat.setBackground(view, drawable);
}
 
Example 11
Source Project: LB-Launcher   File: SearchDropTargetBar.java    License: Apache License 2.0 5 votes vote down vote up
private void prepareStartAnimation(View v) {
    // Enable the hw layers before the animation starts (will be disabled in the onAnimationEnd
    // callback below)
    if (v != null) {
        v.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }
}
 
Example 12
@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 13
Source Project: MiBandDecompiled   File: d.java    License: Apache License 2.0 4 votes vote down vote up
public static void a(View view, int i)
{
    view.setLayerType(i, null);
}
 
Example 14
public static void setLayerType(View view, int layerType) {
	view.setLayerType(layerType, null);
}
 
Example 15
Source Project: ONE-Unofficial   File: ViewCompat.java    License: Apache License 2.0 4 votes vote down vote up
public static void setLayerType(View view, int layerType) {
	view.setLayerType(layerType, null);
}
 
Example 16
Source Project: IntroActivity   File: BaseIntroFragment.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // Set the View layer to a hardware rendering layer
    view.setLayerType(View.LAYER_TYPE_HARDWARE, null);

    // Set a tag on the View so we can use it for custom animations
    view.setTag(this);

    // Title
    TextView title = (TextView) view.findViewById(R.id.title);
    title.setText(getTitle());
    title.setTextColor(getTitleColor());

    // Description
    TextView description = (TextView) view.findViewById(R.id.description);
    description.setText(getDescription());
    description.setTextColor(getDescriptionColor());

    // ViewStub
    ViewStub viewStub = (ViewStub) view.findViewById(R.id.viewstub);
    switch (getResourceType()) {
        // If the resource ID represents a layout ID,
        // inflate the layout based on the ID
        case RESOURCE_TYPE_LAYOUT:
            if (getLayoutId() != 0) {
                viewStub.setLayoutResource(getLayoutId());
                viewStub.inflate();
            }
            break;

        // If the resource ID represents a drawable ID,
        // inflate the drawable layout and set the image resource
        case RESOURCE_TYPE_DRAWABLE:
            viewStub.setLayoutResource(R.layout.drawable_layout);
            viewStub.inflate();

            ImageView imageView = (ImageView) view.findViewById(R.id.imageview);
            imageView.setImageResource(getDrawableId());
            break;
    }
}
 
Example 17
public static void setLayerType(View view, int layerType) {
	view.setLayerType(layerType, null);
}
 
Example 18
public static void setLayerType(View view, int layerType) {
	view.setLayerType(layerType, null);
}
 
Example 19
Source Project: SwipeMenuAndRefresh   File: ViewCompat.java    License: Apache License 2.0 4 votes vote down vote up
public static void setLayerType(View view, int layerType) {
	view.setLayerType(layerType, null);
}
 
Example 20
Source Project: TigerVideo   File: DisplayManager.java    License: Apache License 2.0 4 votes vote down vote up
public static void setLayerType(View view, int layerType, Paint paint) {
    view.setLayerType(layerType, paint);
}