Android 如何确保进度条已停止
我知道要“停止”ProgressBar,需要将其可见性设置为Android 如何确保进度条已停止,android,android-progressbar,Android,Android Progressbar,我知道要“停止”ProgressBar,需要将其可见性设置为View.GONE。但是这真的能阻止它吗?背景中有一个动画,可以为视图设置动画。该动画是否在检测到进度条已消失后停止或不可见?我真的不想在不需要的时候让进度条在后台持续运行。这是对处理能力的浪费 有人知道吗?看着ProgressBar.java我发现: /** * Returns whether the ProgressBar is animating or not. This is essentially the same * a
View.GONE
。但是这真的能阻止它吗?背景中有一个动画,可以为视图设置动画。该动画是否在检测到进度条已消失后停止或不可见?我真的不想在不需要的时候让进度条在后台持续运行。这是对处理能力的浪费
有人知道吗?看着
ProgressBar.java
我发现:
/**
* Returns whether the ProgressBar is animating or not. This is essentially the same
* as whether the ProgressBar is {@link #isIndeterminate() indeterminate} and visible,
* as indeterminate ProgressBars are always animating, and non-indeterminate
* ProgressBars are not animating.
*
* @return true if the ProgressBar is animating, false otherwise.
*/
public boolean isAnimating() {
return isIndeterminate() && getWindowVisibility() == VISIBLE && isShown();
}
void startAnimation() {
if (getVisibility() != VISIBLE || getWindowVisibility() != VISIBLE) {
return;
}
...
@Override
protected void onDetachedFromWindow() {
if (mIndeterminate) {
stopAnimation();
}
...
我认为,ProgressBar
将在隐藏后停止动画