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

The following examples show how to use android.view.View#setLayerType() . 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 check out the related API usage on the sidebar.
Example 1
Source File: PopupWonView.java    From memory-game with 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 File: DynamicGridView.java    From DynamicGrid with 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
Source File: FoldingLayoutActivity.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@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 File: ShadowCircleTransformation.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
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 5
Source File: JazzyViewPager.java    From ClockView with 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 6
Source File: PlaybackOverlaySupportFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
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 File: FlipView.java    From android-FlipView with 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 File: JazzyViewPager.java    From ClockView with 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 File: JazzyViewPager.java    From Gazetti_Newspaper_Reader with MIT License 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 10
Source File: ShadowDrawable.java    From ShadowDrawable with 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 11
Source File: ShadowDrawable.java    From ShadowDrawable with 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 12
Source File: SearchDropTargetBar.java    From LB-Launcher with 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 13
Source File: DisplayManager.java    From TigerVideo with Apache License 2.0 4 votes vote down vote up
public static void setLayerType(View view, int layerType, Paint paint) {
    view.setLayerType(layerType, paint);
}
 
Example 14
Source File: ViewCompat.java    From SwipeMenuAndRefresh with Apache License 2.0 4 votes vote down vote up
public static void setLayerType(View view, int layerType) {
	view.setLayerType(layerType, null);
}
 
Example 15
Source File: ViewCompat.java    From bmob-android-demo-paging with GNU General Public License v3.0 4 votes vote down vote up
public static void setLayerType(View view, int layerType) {
	view.setLayerType(layerType, null);
}
 
Example 16
Source File: ViewCompat.java    From PullToRefresh-PinnedSection-ListView with MIT License 4 votes vote down vote up
public static void setLayerType(View view, int layerType) {
	view.setLayerType(layerType, null);
}
 
Example 17
Source File: BaseIntroFragment.java    From IntroActivity with 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 18
Source File: ViewCompat.java    From ONE-Unofficial with Apache License 2.0 4 votes vote down vote up
public static void setLayerType(View view, int layerType) {
	view.setLayerType(layerType, null);
}
 
Example 19
Source File: ViewCompat.java    From effective_android_sample with 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 File: d.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public static void a(View view, int i)
{
    view.setLayerType(i, null);
}