Java 如何创建一个;“填写”;Android中的动画
我正在尝试在Android中的形状上创建一个“填充”动画。它应该开始完全看不见,然后从底部逐渐“填满”,如下所示: 我特别想要制作的是一个圆,比如:Java 如何创建一个;“填写”;Android中的动画,java,android,animation,android-animation,Java,Android,Animation,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
<?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>
我已经检查了AlphaAnimation、RotateAnimation、ScaleAnimation和TranslateAnimation(动画的子类),但是我找不到一种方法来使用它们 您可以深入研究动画,如drawPath等。在这种情况下,我应该做的更简单一点:
-在屏幕上放置一个完整的红色圆圈
-在其上方放置一个带有白色背景的视图(如正方形),覆盖所有圆圈
-设置白色方形视图向上移动的动画,显示您的圆
您可以使用一个简单的过渡动画来完成此操作。
这样看起来就像你想要的填充动画。
好的,我的答案是你提供的以下图片,它足够好地覆盖了目标。但是,如果你想让进度条看起来像这样,你应该访问并检查那里的循环进度条库,至少你会知道如何实现你的目标,或者知道它已经完成了。以下是我最终解决它的方法: 我从github中包括了这个库,它包含一个圆形进度条(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();
感谢斯坦给我指点圆形进度条 谢谢你的回答!这似乎是个好主意。唯一的问题是,在我的圆圈上面会有这样一个正方形会隐藏的内容…@wallen刚刚检查了图片,似乎删除了。请上传一张新图片