本文整理汇总了Java中android.support.animation.SpringAnimation类的典型用法代码示例。如果您正苦于以下问题:Java SpringAnimation类的具体用法?Java SpringAnimation怎么用?Java SpringAnimation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpringAnimation类属于android.support.animation包,在下文中一共展示了SpringAnimation类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initIconAnimation
import android.support.animation.SpringAnimation; //导入依赖的package包/类
/**
* 初始化开始动画
*/
private void initIconAnimation() {
int screenH = DensityUtil.getScreenH(this);
SpringForce springForce = new SpringForce()
.setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY)
.setStiffness(SpringForce.STIFFNESS_VERY_LOW)
.setFinalPosition(0);
SpringAnimation springAnimation = new SpringAnimation(mCivIcon, DynamicAnimation.TRANSLATION_Y)
.setSpring(springForce)
.setStartValue(screenH);
springAnimation.addEndListener(new DynamicAnimation.OnAnimationEndListener() {
@Override
public void onAnimationEnd(DynamicAnimation animation, boolean canceled, float value, float velocity) {
initTextAnimation();
}
});
springAnimation.start();
}
开发者ID:coderwjq,项目名称:ZhaZhaShop,代码行数:24,代码来源:SplashActivity.java
示例2: animateSettle
import android.support.animation.SpringAnimation; //导入依赖的package包/类
void animateSettle(int targetOffset, float initialVelocity) {
if (settling) return;
if (sheetOffsetHelper.getTopAndBottomOffset() == targetOffset) {
if (targetOffset >= dismissOffset) {
dispatchDismissCallback();
}
return;
}
settling = true;
final boolean dismissing = targetOffset == dismissOffset;
// if we're dismissing, we don't want the view to decelerate as it reaches the bottom
// so set a target position that actually overshoots a little
final float finalPosition = dismissing ? dismissOffset * 1.1f : targetOffset;
SpringAnimation anim = new SpringAnimation(
sheetOffsetHelper, ViewOffsetHelper.OFFSET_Y, finalPosition)
.setStartValue(sheetOffsetHelper.getTopAndBottomOffset())
.setStartVelocity(initialVelocity)
.setMinimumVisibleChange(DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS);
anim.getSpring()
.setStiffness(SETTLE_STIFFNESS)
.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY);
anim.addEndListener((animation, canceled, value, velocity) -> {
dispatchPositionChangedCallback();
if (dismissing) {
dispatchDismissCallback();
}
settling = false;
});
if (callbacks != null && !callbacks.isEmpty()) {
anim.addUpdateListener((animation, value, velocity) -> dispatchPositionChangedCallback());
}
anim.start();
}
开发者ID:nickbutcher,项目名称:plaid,代码行数:36,代码来源:BottomSheet.java
示例3: onCreate
import android.support.animation.SpringAnimation; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mVelocityTracker = VelocityTracker.obtain();
final ImageView droid = (ImageView) findViewById(R.id.droid);
findViewById(android.R.id.content).setOnTouchListener(new View.OnTouchListener() {
private final Rect mRect = new Rect();
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mDownX = event.getX();
mDownY = event.getY();
mVelocityTracker.addMovement(event);
return true;
case MotionEvent.ACTION_MOVE:
float x = event.getX();
float y = event.getY();
droid.getHitRect(mRect);
if (mRect.contains((int) x, (int) y)) {
droid.setTranslationX(x - mDownX);
droid.setTranslationY(y - mDownY);
mVelocityTracker.addMovement(event);
}
return true;
case MotionEvent.ACTION_UP:
// fall-thru
case MotionEvent.ACTION_CANCEL:
mVelocityTracker.computeCurrentVelocity(1000);
if (droid.getTranslationX() != 0) {
SpringAnimation animX = new SpringAnimation(droid, SpringAnimation.TRANSLATION_X, 0);
animX.getSpring().setStiffness(getStiffness());
animX.getSpring().setDampingRatio(getDamping());
animX.setStartVelocity(mVelocityTracker.getXVelocity());
animX.start();
}
if (droid.getTranslationY() != 0) {
SpringAnimation animY = new SpringAnimation(droid, SpringAnimation.TRANSLATION_Y, 0);
animY.getSpring().setStiffness(getStiffness());
animY.getSpring().setDampingRatio(getDamping());
animY.setStartVelocity(mVelocityTracker.getYVelocity());
animY.start();
}
mVelocityTracker.clear();
return true;
}
return false;
}
});
}
开发者ID:mightyfrog,项目名称:Dynamic-Animation-Sample,代码行数:55,代码来源:MainActivity.java
注:本文中的android.support.animation.SpringAnimation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论