相关疑难解决方法(0)

Android中的动画ProgressBar更新

我在我的应用程序中使用ProgressBar,我在onProgressUpdate中更新AsyncTask.到现在为止还挺好.

我想要做的是为进度更新设置动画,这样它不仅可以"跳转"到值,而且可以平滑地移动到它.

我尝试这样做运行以下代码:

this.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            while (progressBar.getProgress() < progress) {
                progressBar.incrementProgressBy(1);
                progressBar.invalidate();
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }

    });
Run Code Online (Sandbox Code Playgroud)

问题是进度条在完成其最终值(进度变量)之前不会更新其状态.中间的所有状态都不会显示在屏幕上.调用progressBar.invalidate()也没有帮助.

有任何想法吗?谢谢!

user-interface animation android progress-bar

53
推荐指数
7
解决办法
5万
查看次数

如何在android中为progressBar设置流畅的动画

在我的项目中我想使用ProgressBar并且我想设置平滑倒计时动画

我下面写的代码顺利动画,当一套1000毫秒(1秒)时间演出顺利 animation,但我想要一套10000ms(10秒)时间

当持续时间设置为 10000 毫秒(10 秒)时,动画不流畅并显示片段倒计时。

但我想一套10000ms时间,并显示顺利倒计时

public class SimpleFrag extends Fragment {

    TextView toolbar_title;
    RelativeLayout toolbar;
    private ProgressBar progressBar;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_simple, container, false);

        ButterKnife.bind(this, view);
        toolbar_title = getActivity().findViewById(R.id.toolbar_title);
        toolbar = getActivity().findViewById(R.id.toolbar);
        progressBar = view.findViewById(R.id.progress);

        return view;
    } …
Run Code Online (Sandbox Code Playgroud)

animation android android-animation android-progressbar

2
推荐指数
1
解决办法
4880
查看次数