本文整理汇总了Java中android.animation.ObjectAnimator.ofObject方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectAnimator.ofObject方法的具体用法?Java ObjectAnimator.ofObject怎么用?Java ObjectAnimator.ofObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.animation.ObjectAnimator
的用法示例。
在下文中一共展示了ObjectAnimator.ofObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDrawState
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
@Override
public void onDrawState(final EmptyStateRecyclerView rv, Canvas canvas) {
canvas.drawText(title,
(rv.getMeasuredWidth() >> 1),
(rv.getMeasuredHeight() >> 1),
textPaint);
// Setup animator, if necessary
if (anim == null) {
this.anim = ObjectAnimator.ofObject(textPaint, "color", new ArgbEvaluator(),
Color.parseColor("#E0E0E0"), Color.parseColor("#BDBDBD"), Color.parseColor("#9E9E9E"));
this.anim.setDuration(900);
this.anim.setRepeatMode(ValueAnimator.REVERSE);
this.anim.setRepeatCount(ValueAnimator.INFINITE);
this.anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
rv.invalidate();
}
});
this.anim.start();
}
}
示例2: onDrawState
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
@Override
public final void onDrawState(final EmptyStateRecyclerView rv, Canvas canvas) {
final int width = rv.getMeasuredWidth();
final int height = rv.getMeasuredHeight();
// Draw all of our content items
renderContent(numberOfContentItems, width, height, canvas, contentPaint);
// Setup and start animation, if possible
if (animateContentItems) {
if (anim == null) {
this.anim = ObjectAnimator.ofObject(contentPaint, "color", new ArgbEvaluator(),
Color.parseColor("#E0E0E0"), Color.parseColor("#BDBDBD"), Color.parseColor("#9E9E9E"));
onInterceptAnimatorCreation(anim);
this.anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
rv.invalidate();
}
});
this.anim.start();
}
}
}
示例3: startAnim
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
/**
* 给背景设置一个动画
*
* @param endProgress 动画的结束进度
* @param endCallback 动画结束时触发
*/
private void startAnim(float endProgress, final Runnable endCallback) {
// 获取一个最终的颜色
int finalColor = Resource.Color.WHITE; // UiCompat.getColor(getResources(), R.color.white);
// 运算当前进度的颜色
ArgbEvaluator evaluator = new ArgbEvaluator();
int endColor = (int) evaluator.evaluate(endProgress, mBgDrawable.getColor(), finalColor);
// 构建一个属性动画
ValueAnimator valueAnimator = ObjectAnimator.ofObject(this, property, evaluator, endColor);
valueAnimator.setDuration(1500); // 时间
valueAnimator.setIntValues(mBgDrawable.getColor(), endColor); // 开始结束值
valueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
// 结束时触发
endCallback.run();
}
});
valueAnimator.start();
}
示例4: animateCheckedState
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
@SuppressLint("ObsoleteSdkInt")
private void animateCheckedState(boolean newCheckedState) {
AnimatorProperty property = new AnimatorProperty();
if (newCheckedState) {
property.color = onColor;
property.offLineWidth = 10;
property.spotX = spotMaxX;
} else {
property.color = offBorderColor;
property.offLineWidth = spotSize;
property.spotX = spotMinX;
}
if (mAnimator == null) {
mAnimator = ObjectAnimator.ofObject(this, ANIM_VALUE, new AnimatorEvaluator(mCurProperty), property);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)
mAnimator.setAutoCancel(true);
mAnimator.setDuration(ANIMATION_DURATION);
mAnimator.setInterpolator(ANIMATION_INTERPOLATOR);
} else {
mAnimator.cancel();
mAnimator.setObjectValues(property);
}
mAnimator.start();
}
示例5: openMenu
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
/**
* Call this function to open menu.
*/
private void openMenu() {
ObjectAnimator animator = ObjectAnimator.ofObject(this, "path", new CirclePathEvaluator(circlePathRadius, viewCircleCenterX, viewCircleCenterY, CirclePathEvaluator.OPEN, isClockwise), startPathPoints, endPathPoints);
animator.setInterpolator(new DecelerateInterpolator());
animator.setDuration(period);
animator.start();
//menuOpening = true;
menuStatus = OPENING;
if (onMenuSwitchListener != null) {
onMenuSwitchListener.onMenuSwitch(OPENING, currentIndex);
}
}
示例6: closeMenu
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
/**
* Call this function to close menu.
*/
private void closeMenu() {
ObjectAnimator animator = ObjectAnimator.ofObject(this, "path", new CirclePathEvaluator(circlePathRadius, viewCircleCenterX, viewCircleCenterY, CirclePathEvaluator.CLOSE, isClockwise), startPathPoints, endPathPoints);
animator.setInterpolator(new DecelerateInterpolator());
animator.setDuration(period);
animator.start();
//menuOpening = false;
menuStatus = CLOSING;
if (onMenuSwitchListener != null) {
onMenuSwitchListener.onMenuSwitch(CLOSING, currentIndex);
}
}
示例7: ActionModeCallback
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public ActionModeCallback(Activity activity, ActionListener listener) {
context = activity;
window = activity.getWindow();
actionListener = listener;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
statusBarColor = window.getStatusBarColor();
int actionModeStatusBarColor = ContextCompat.getColor(context,
R.color.mp_theme_dark_blue_actionMode_statusBarColor);
int startColor = Color.argb(
0,
Color.red(actionModeStatusBarColor),
Color.green(actionModeStatusBarColor),
Color.blue(actionModeStatusBarColor)
);
actionModeInAnimator = ObjectAnimator.ofObject(
window,
STATUS_BAR_COLOR,
new ArgbEvaluator(),
startColor,
actionModeStatusBarColor
);
actionModeOutAnimator = ObjectAnimator.ofObject(
window,
STATUS_BAR_COLOR,
new ArgbEvaluator(),
actionModeStatusBarColor,
startColor
);
actionModeInAnimator.setDuration(ANIMATION_DURATION);
actionModeOutAnimator.setDuration(ANIMATION_DURATION);
}
}
示例8: performColorSwapAnimation
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public static void performColorSwapAnimation(FullscreenBaseGameActivity context, Integer[] shuffle, List<Button> buttons, FrameLayout[] layouts) {
for (int i = 0; i < buttons.size(); i++) {
int index = shuffle[i];
layouts[i].addView(buttons.get(index));
ObjectAnimator objectAnimator = ObjectAnimator.ofObject(buttons.get(i), "backgroundColor",
new ArgbEvaluator(),
ContextCompat.getColor(context, SimonColorImpl.getColorIdFromButtonId(buttons.get(index).getId())),
ContextCompat.getColor(context, SimonColorImpl.getColorIdFromButtonId(buttons.get(i).getId())));
objectAnimator.setRepeatCount(0);
objectAnimator.setRepeatMode(ValueAnimator.REVERSE);
objectAnimator.setDuration(300);
objectAnimator.start();
}
}
示例9: LQRRefreshButton
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public LQRRefreshButton(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
// 获取自定义属性值
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.LQRRefreshButton);
borderColor = ta.getColor(R.styleable.LQRRefreshButton_refresh_btn_borderColor, Color.parseColor("#fb7299"));
borderWidth = ta.getDimension(R.styleable.LQRRefreshButton_refresh_btn_borderWidth, dipToPx(0));
borderRadius = ta.getDimension(R.styleable.LQRRefreshButton_refresh_btn_borderRadius, dipToPx(60));
text = ta.getString(R.styleable.LQRRefreshButton_refresh_btn_text);
if (text == null)
text = "";
textColor = ta.getColor(R.styleable.LQRRefreshButton_refresh_btn_textColor, Color.parseColor("#fb7299"));
textSize = ta.getDimension(R.styleable.LQRRefreshButton_refresh_btn_textSize, spToPx(14));
iconSrc = ta.getResourceId(R.styleable.LQRRefreshButton_refresh_btn_iconSrc, R.mipmap.tag_center_refresh_icon);
iconSize = ta.getDimension(R.styleable.LQRRefreshButton_refresh_btn_iconSize, dipToPx(14));
space4TextAndIcon = ta.getDimension(R.styleable.LQRRefreshButton_refresh_btn_space4TextAndIcon, dipToPx(10));
ta.recycle();
// icon
iconBitmap = BitmapFactory.decodeResource(getResources(), iconSrc);
iconBitmap = zoomImg(iconBitmap, iconSize, iconSize);
// 旋转动画
mAnimator = ObjectAnimator.ofObject(this, "degress", new FloatEvaluator(), 360, 0);
mAnimator.setDuration(2000);
mAnimator.setRepeatMode(ObjectAnimator.RESTART);
mAnimator.setInterpolator(new LinearInterpolator());
mAnimator.setRepeatCount(ObjectAnimator.INFINITE);
}
示例10: animate
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public ObjectAnimator animate(int start, int end) {
float[][] startPoints = NumberUtils.getControlPointsFor(start);
float[][] endPoints = NumberUtils.getControlPointsFor(end);
return ObjectAnimator.ofObject(this, CONTROL_POINTS_PROPERTY, new TimelyEvaluator(), startPoints, endPoints);
}
示例11: fadeColoTo
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void fadeColoTo(int newColor, TextView view)
{
ObjectAnimator color = ObjectAnimator.ofObject(view, "TextColor", new ArgbEvaluator(), view.getCurrentTextColor(), newColor);
color.setDuration(200);
color.start();
}
示例12: ofColor
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public static ObjectAnimator ofColor(Object target, String propertyName, int from, int to) {
return ObjectAnimator.ofObject(target, propertyName, new ColorEvaluator(), from, to);
}
示例13: ofBackgroundColor
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public static ObjectAnimator ofBackgroundColor(View target, int from, int to) {
return ObjectAnimator.ofObject(new ViewBackgroundWrapper(target), "backgroundColor", new ColorEvaluator(), from, to);
}
示例14: fadeColoTo
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void fadeColoTo(int newColor, TextView view) {
ObjectAnimator color = ObjectAnimator.ofObject(view, "TextColor", new ArgbEvaluator(), view.getCurrentTextColor(), newColor);
color.setDuration(200);
color.start();
}
示例15: toAlphaOne
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public static ObjectAnimator toAlphaOne(View view, int duration) {
ObjectAnimator objectAnimator = ObjectAnimator.ofObject(view, "alpha", new FloatEvaluator(), 0.0f, 1.0f);
objectAnimator.setDuration(duration);
return objectAnimator;
}