/** * 控件初始化 **/ private void init() { LayoutInflater.from(mContext).inflate(R.layout.layout_vertical_notication_scroll_bar, this); mSwitchViewGroup = (SwitchViewGroup) findViewById(R.id.switchViewGroup); ll_vertical_notication_scroll_bar_container = (LinearLayout) findViewById(R.id.ll_vertical_notication_scroll_bar_container); iv_layout_vertical_notication_scroll_bar_close = (ImageView) findViewById(R.id.iv_layout_vertical_notication_scroll_bar_close); iv_layout_vertical_notication_scroll_bar_close.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { closeScrollBar(); } }); mDatas = new ArrayList<>(); tempArgbEvaluator = new ArgbEvaluator(); mMhandler = new Handler(); }
private void initView() { removeAllViews(); addView(LayoutInflater.from(getContext()).inflate(R.layout.layout_check_header, null), LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); ivLight = findViewById(R.id.iv_light); tvStatus = (TextView) findViewById(R.id.tv_check_status); btnCheck = (Button) findViewById(R.id.btn_check); llPoints = (LinearLayout) findViewById(R.id.ll_points); tvPoints = (TextView) findViewById(R.id.tv_points); btnCheck.setOnClickListener(checkClick); bgBeginColor = getResources().getColor(R.color.check_points_begin); bgEndColor = getResources().getColor(R.color.check_points_end); bgMiddleColor = getResources().getColor(R.color.check_points_middle); bgEvaluator = new ArgbEvaluator(); setPassedCheckCount(0); }
private void initView() { removeAllViews(); addView(LayoutInflater.from(getContext()).inflate(R.layout.layout_r_check_header, null), LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); ivLight = findViewById(R.id.iv_light); tvStatus = (TextView) findViewById(R.id.tv_check_status); ibtnCheck = (ImageButton) findViewById(R.id.ibtn_check); llPoints = (LinearLayout) findViewById(R.id.ll_points); tvPoints = (TextView) findViewById(R.id.tv_points); flBottom = (FrameLayout) findViewById(R.id.fl_bottom); findViewById(R.id.ibtn_rcheck_info).setOnClickListener(infoClick); ibtnCheck.setOnClickListener(checkClick); bgBeginColor = getResources().getColor(R.color.check_points_begin); bgEndColor = getResources().getColor(R.color.rcheck_end); bgMiddleColor = getResources().getColor(R.color.check_points_middle); bgEvaluator = new ArgbEvaluator(); setPassedCheckCount(0); }
private void onFlagChanged(final CardFlag oldFlag, final CardFlag newFlag) { int flagColor = CARD_BACKGROUND_COLOR_NOFLAG; if (newFlag != null) { flagColor = newFlag.getColor(); } ValueAnimator fade = ObjectAnimator.ofInt(mCardPaint, "color", mCardPaint.getColor(), flagColor); fade.setDuration(500); fade.setEvaluator(new ArgbEvaluator()); fade.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator value) { onFlagChangedUpdate(oldFlag, newFlag, value); invalidate(); } }); fade.start(); }
/** * Background color animation builder. * * @param colors the colors * @return the animation builder */ public AnimationBuilder backgroundColor(int... colors) { for (View view : views) { ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view, "backgroundColor", colors); objectAnimator.setEvaluator(new ArgbEvaluator()); this.animatorList.add(objectAnimator); } return this; }
/** * Text color animation builder. * * @param colors the colors * @return the animation builder */ public AnimationBuilder textColor(int... colors) { for (View view : views) { if (view instanceof TextView) { ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view, "textColor", colors); objectAnimator.setEvaluator(new ArgbEvaluator()); this.animatorList.add(objectAnimator); } } return this; }
public AnimationBuilder backgroundColor(int... colors) { for (View view : this.views) { ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view, "backgroundColor", colors); objectAnimator.setEvaluator(new ArgbEvaluator()); this.animatorList.add(objectAnimator); } return this; }
public AnimationBuilder textColor(int... colors) { for (View view : this.views) { if (view instanceof TextView) { ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view, "textColor", colors); objectAnimator.setEvaluator(new ArgbEvaluator()); this.animatorList.add(objectAnimator); } } return this; }
public MyAnimationView(Context context) { super(context); // Animate background color // Note that setting the background color will automatically invalidate the // view, so that the animated color, and the bouncing balls, get redisplayed on // every frame of the animation. ValueAnimator colorAnim = ObjectAnimator.ofInt(this, "backgroundColor", RED, BLUE); colorAnim.setDuration(3000); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.setRepeatCount(ValueAnimator.INFINITE); colorAnim.setRepeatMode(ValueAnimator.REVERSE); colorAnim.start(); }
private void init() { mColorEvaluator = new ArgbEvaluator(); }
/** * 根据指定的颜色来创建颜色动画 * @param colors 指定的颜色 */ private void createAnimation(int... colors) { colorAnim = ObjectAnimator.ofInt(this, "backgroundColor", colors); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.setDuration(DURATION); }
@Override protected void buildAnimator() { ObjectAnimator animator = (ObjectAnimator) getAnimator(); if (animator == null) { if (mPropertyType == PropertyDataType.UNKNOWN) { Log.w(TAG, "Property data type unknown, cannot animate."); return; } Object target = getTarget(); String propertyName = AnimationUtils.translatePropertyName(target, mPropertyName); Object actualObject = target; if (target instanceof TiViewProxy) { TiUIView intermediateObject = ((TiViewProxy) target).peekView(); if (intermediateObject != null) { actualObject = intermediateObject.getNativeView(); if (actualObject != null && propertyName.equals(PROPERTY_BACKGROUND_COLOR) && mIntValues.length == 1) { // There is no "getBackgroundColor" on Android views, // so we wrap it. actualObject = new ViewWrapper((View) actualObject); } } else { Log.w(TAG, "View not available for animation."); } } if (actualObject == null) { Log.w(TAG, "Object not available for animation (null)."); return; } switch (mPropertyType) { case FLOAT: animator = ObjectAnimator.ofFloat(actualObject, propertyName, mFloatValues); break; case INT: animator = ObjectAnimator.ofInt(actualObject, propertyName, mIntValues); break; case UNKNOWN: break; } } if (mRepeatCount != AndroidAnimation.NO_INT_VALUE) { animator.setRepeatCount(mRepeatCount); } if (mRepeatMode != AndroidAnimation.NO_INT_VALUE) { animator.setRepeatMode(mRepeatMode); } if (mEvaluator != AndroidAnimation.NO_INT_VALUE) { switch (mEvaluator) { case AndroidAnimation.INT_EVALUATOR: animator.setEvaluator(new IntEvaluator()); break; case AndroidAnimation.FLOAT_EVALUATOR: animator.setEvaluator(new FloatEvaluator()); break; case AndroidAnimation.ARGB_EVALUATOR: animator.setEvaluator(new ArgbEvaluator()); break; default: Log.w(TAG, "Evaluator set to unknown value: " + mEvaluator); } } setAnimator(animator); super.setCommonAnimatorProperties(); }
@NonNull public Animator color(int from, int to, float duration, @Nullable Interpolator interpolator, boolean isText) { ObjectAnimator animator; if (mView instanceof TextView && isText) { TextView tv = (TextView) mView; tv.setTextColor(from); animator = ObjectAnimator.ofInt(mView, "textColor", from, to); } else { mView.setBackgroundColor(from); animator = ObjectAnimator.ofInt(mView, "backgroundColor", from, to); } setProperties(animator, duration, interpolator); animator.setEvaluator(new ArgbEvaluator()); return animator; }