Android:显示Google在其应用中所做的进度圈

Pas*_*ein 13 android progress

我正在使用AsyncTask为我的Listview下载图像,因为我不希望下载图像来阻止我的UI-Thread.在加载图像时,我想在图像所在的位置显示一个动画进度圆.

但我找不到进步圈的图像.什么是Ressource-Id?或者还有其他方法吗?有人有这个图像的链接?

小智 22

查看进度条.它可以在不确定的模式下工作(默认情况下,它确实是AFAIR),这意味着它显示一个旋转的圆圈,就像你要求的那样.我知道这不是一个图像,但你可以做的是放置一个FrameLayout而不是图像,进度条是唯一的孩子.然后,一旦加载图像完成,删除进度条并添加图像.


bli*_*uff 11

将此定义为全局变量 ProgressDialog pd;

就在启动AsyncTask之前:

pd = ProgressDialog.show(CurrentClassName.this,"This is the title","This is the detail text",true,false,null);
Run Code Online (Sandbox Code Playgroud)

当它完成onPostExecute后才打电话pd.dismiss();

有关更多详细信息,请参阅:ProgressDialog

在对话框启动时旋转设备时,您必须特别注意它才能工作.


wzb*_*zon 5

这是带有图像和圆形进度条的介绍活动的布局文件示例:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/intro_description"
        android:scaleType="fitXY"
        android:src="@drawable/intro" />

    <ProgressBar
        android:id="@+id/progress"
        style="?android:attr/progressBarStyleInverse"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="150dp"
        android:visibility="visible" />

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)