【问题标题】:how to display a animated progress before image download using Universal Image loader如何使用通用图像加载器在图像下载之前显示动画进度
【发布时间】:2015-09-30 22:10:10
【问题描述】:

我有一个列表,其中显示文本、图像和 4 个选项(A、B、C、D)

我正在使用通用图像加载器来处理图像,我的要求是我必须在下载后将出现的图像精确大小的位置显示一个小的动画进度条,

任何人都可以建议我如何实现这一目标,我正在为此苦苦挣扎。慢慢学习android UI。请帮帮我

以下是参考代码

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

            <TextView
                android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_marginTop="8dp"
                android:textColor="#d9000000"
                android:textSize="20sp"
                android:textStyle="bold"
                />

            <TextView
                android:id="@+id/body"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_marginTop="8dp"
                android:ellipsize="end"
                android:lineSpacingMultiplier="1.4"
                android:maxLines="4"
                android:textColor="#d9000000"
                android:textSize="16sp"
                />

            <ImageView
                android:id="@+id/image"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                />
        </LinearLayout>

并在列表适配器中使用以下代码上传图片

mDisplayImageOptions = new DisplayImageOptions.Builder()
                .cacheInMemory(true)
                .cacheOnDisk(true)
                .build();

mImageLoader.displayImage(url, mImageView, mDisplayImageOptions);

我已经检查了下面的链接,但没有工作

Show indeterminate ProgressBar while loading image with Universal Image Loader

【问题讨论】:

标签: android android-imageview universal-image-loader


【解决方案1】:

只需使用相对布局将进度条放在图像视图下,这样一旦图像视图不为空,它将覆盖/隐藏进度条,如下所示:

 <LinearLayout >

       .........

    <RelativeLayout 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp">

       <ProgressBar
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:id="@+id/progressBar"
           android:layout_centerVertical="true"
           android:layout_centerHorizontal="true" />

        <ImageView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
     </RelativeLayout>  

【讨论】:

  • 让我试试会让你知道的
  • 你能建议我如何将它与通用图像加载器一起使用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-19
  • 2019-10-28
  • 2017-05-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多