如何显示加载进度动画一些图像? [英] How to display load progress animation for some image?

查看:147
本文介绍了如何显示加载进度动画一些图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示进度条(以旋转一圈或类似的形式)从装载远程图像时。

I would like to show progress bar (in form of rotating circle or something similar) when loading image from remote location.

我不希望被显示在屏幕的中间标准进度。我想有它在ImageView的(或布局保存的ImageView)的中间。有没有简单的方法来做到这一点?例如,我有选择的进度附加到某些View?

I don't want standard ProgressBar that gets shown in the middle of the screen. I would like to have it in the middle of the imageView (or Layout that holds ImageView). Is there easy way to do this? For example, do I have option to attach progressBar to some View?

我在读有关FrameAnimation。我想我能做到这一点,但首先我想确保我不会重蹈覆辙。

I was reading about FrameAnimation. I think I will do that, but first I want to make sure that I am not reinventing the wheel.

感谢。

推荐答案

你的意思是像一个微调?

Do you mean like a spinner ?

是的,你可以这样做:

继承人的样本code:

heres a sample code:

<!--Grey Spinner-->
<ProgressBar
    android:id="@android:id/progress"
    style="?android:attr/progressBarStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
/>
<!--Black Spinner-->
<ProgressBar
    android:id="@android:id/progress"
    style="?android:attr/progressBarStyleSmallInverse"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
/>

下面是一些其他的样式属性,你可以使用,只需更换上面的风格,其中的一个,如属性风格=机器人:ATTR /&LT;从下面列表&gt属性之一;

Here are some other style attributes you can use, just replace above style attributes with one of these, e.g. style=?android:attr/<one of the attribute from below list>

    progressBarStyleSmallTitle
    progressBarStyleLarge
    progressBarStyleLargeInverse
    progressBarStyleHorizontal
    progressBarStyleSmallTitle

您还必须注意,如果你是从互联网上下载的图像不使用UIThread。而且你还可以在标题栏添加进度条。

You must also note that if you are downloading image from internet do not use UIThread. And you can also add progress bar in the title bar.

添加微调器标题栏具有以下code(呼叫请求。在的onCreate()):

Add spinner to title bar with following code(call request.. in onCreate()):

requestWindowFeature(Window.FEATURE_PROGRESS);
//calling setContentView() after requesting
setContentView(R.layout.main);
setProgressBarVisibility(true);
//call setProgressBarVisibility(false); to turn it off

希望这有助于。 干杯!

Hope this helps. Cheers!

这篇关于如何显示加载进度动画一些图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆