简体   繁体   English

Android进度栏持续旋转

[英]Android progress bar keeps spinning

I'm trying to use a progress bar (the normal one, not the horizontal one) as a compass of sorts, but for some reason the bar just keeps spinning without control. 我正在尝试使用进度条(普通的而不是水平的)作为指南针,但是由于某种原因,进度条只是在不受控制的情况下不断旋转。 I've set the indeterminate to false, both in the xml and in the attached Java code, but it seems to do nothing. 在xml和附加的Java代码中,我都将indeterminate设置为false,但这似乎无济于事。

This is the xml code for the View: 这是视图的xml代码:

    <ProgressBar
        android:id="@+id/brujula"
        style="?android:attr/progressBarStyle"
        android:layout_width="229dp"
        android:layout_height="507dp"
        android:layout_marginStart="91dp"
        android:layout_marginTop="90dp"
        android:layout_marginEnd="91dp"
        android:layout_marginBottom="135dp"
        android:visibility="invisible"
        android:indeterminate="false"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

The code I'm using to set it to false in Java too is 我也在Java中将其设置为false的代码也是

ProgressBar brujula = (ProgressBar) FindViewById(R.id.brujula);
brujula.setIndeterminate(false);

I have no idea whatsoever of why it keeps doing that, so any help at all will be appreciated 我不知道为什么它会继续这样做,所以我们将不胜感激

If you want to use the Progress bar again it's better to just hide it: 如果您想再次使用进度栏 ,最好将其隐藏起来:

brujula.setVisibility(View.GONE);

Or you can remove it completely: 或者您可以将其完全删除:

((ViewGroup) brujula.getParent()).removeView(brujula);

hi try this if you want to show progressbar do like this. 嗨,如果您想显示进度栏,请尝试此操作。

ProgressBar brujula = (ProgressBar) FindViewById(R.id.brujula);
brujula.setVisibility(View.VISIBLE);

and where you want to stop loading and want to hide progressbar use 以及要停止加载并隐藏进度栏使用的位置

brujula.setVisibility(View.GONE);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM