Fre*_*lén 3 java animation android android-animation
我正在尝试在Android中的形状上创建"填充"动画.它应该开始完全不可见,然后逐渐从底部"填满",如下所示:

我特意尝试动画的是一个像这样的圆圈:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="#666666"/>
<size
android:width="120dp"
android:height="120dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
我已经检查了AlphaAnimation,RotateAnimation,ScaleAnimation和TranslateAnimation(动画的子类),但我找不到使用它们的方法.
以下是我最终解决的方法:
我从github https://github.com/lzyzsd/CircleProgress中包含了这个库,其中包含一个循环进度条(CircleProgress).我添加了一个倒计时器来逐渐增加它显示的"进度"
这是代码:
final CircleProgress circularProgress =(CircleProgress)findViewById(R.id.circleProgress);
//Hides the text and the part of the circle which should not be shown
circularProgress.setUnfinishedColor(Color.parseColor("#00000000"));
circularProgress.setTextColor(Color.parseColor("#00000000"));
//Makes the circle red
circularProgress.setFinishedColor("#FF0000");
final int timeToCountDownMilis = 10000;
circularProgress.setMax(timeToCountDownMilis);
//Initiates and starts the countdowntimer which gradually increases the "progress" in the progress bar
new CountDownTimer(timeToCountDownMilis,70){
onTick(long milisUntilFinished){
circularProgress.setProgress(timeToCountDownMilis-(int)milisUntilFinished);
}
onFinish(){
}
}.start();
Run Code Online (Sandbox Code Playgroud)
感谢Stan指点我的圆形进度条吧!
| 归档时间: |
|
| 查看次数: |
4609 次 |
| 最近记录: |