使用图象是最简单的解决办法。 您可创建自己的或尝试,并结合多个网站 :TranslateAnimations>和/strong>。
这将意味着将每一数字放在自己的文本意见中,而不是使用滚动观点。
然后,你可以控制中间的加速度,使用<>Interpolator。 国际刑警组织人员正在如何缓解安乐施。 您可能希望<>。 加速效应/放慢效应。
您可使用<>AnimationSet,对同一观点适用多种分析。 展示如何汇集一个好的阿尼松森Set将是该项目中最具挑战性的一部分。 确保注意“填充”财产。 事实上,在玩 playing后,我认为,习惯的估算比使用已准备好的估算更为简单。
https://github.com/pajtai/CountDown/“rel=“nofollow” 4月17日,在我使用多处预言之前,我做了总结。 如果你看一下最新版本,你就会看到习俗的估算。
每次算术的时间在你确定一次算术的期限之后,就自行决定。 A <Handler ,在前一次完稿之后打下一个号码。 我认为,这比要求每十秒都要求一项职能来更新所有内容,没有什么意义。
职能大纲:
- An Activity (CountDownActivity.java) over sees everything.
- The Activitiy s layout XML has a button that is used to start the count down.
- Once the countdown starts, the button disappears. It reappears when the count down is done.
- The Activity contains a Handler (MotionHandler.java). The Handler controls the movement and timing of the numbers.
- The Handler uses a AnimationSet to move the numbers
- The AnimationSet is a passed in dependency
- This is for flexibility. Simply pass in a different AnimationSet to change how the numbers move
- The AnimationSet is made of
four Animations a custom Animation (see below)
- The AnimationSet uses a shared AccelerateDecelerateInterpolator, which seems to work decently. There are other options, including writing your own.
- The Handler uses a delayed message to start the next number
- The Handler notifies the Activity when the count down is done using a custom listener (MotionHandler >> CountdownListener)
- Rotating the device will restart the count down.
注 - 此前,我曾用四张已准备好的阿尼丁松语,我已编辑,仅包括一种习俗。 你可以将其算法推给你的灵魂。
这一习俗的估算使用了Cyclvil,使数字大为小。
/**
* A custom animation to move and scale the numbers.
*
*/
public class NumberAnimation extends Animation
{
final public static float MINIMUM = 3;
private int mHorizontal;
private int mScaling;
public NumberAnimation(int horizontalMovement, int scaling)
{
mHorizontal = horizontalMovement;
mScaling = scaling;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t)
{
// Cycloid repeats every 2pi - scale interpolatedTime to that
double time = 2 * Math.PI * interpolatedTime;
// Cycloid function
float currentScale = (float) (mScaling * (1 - Math.cos(time))) + MINIMUM;
Matrix matrix = t.getMatrix();
matrix.preScale(currentScale, currentScale);
matrix.postTranslate(mHorizontal * interpolatedTime, 0);
}
}