【问题标题】:How to place progressbar on a layout element like a textview or an imageview in android如何在布局元素上放置进度条,如 android 中的 textview 或 imageview
【发布时间】:2017-06-08 06:10:14
【问题描述】:

我正在使用 Retrofit 从服务器加载列表。 谁能帮助我如何在 RecyclerView 中的 CardView 的每个元素上加载 ProgressBar? 下面我发布了我想要做的事情的图片。

编辑:

 <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/viewMargin"
            android:id="@+id/rvRecyclerViewCustom"
            >
  </android.support.v7.widget.RecyclerView>

【问题讨论】:

  • 发布您的 RecyclerView 项目的布局 XML。
  • 没有简单的方法。将您的 ImageViewProgressBar 包裹在 FrameLayout 中。然后,当您的图像加载时,隐藏ProgressBar。大多数图像加载库都提供了这样做的方法。
  • @Ali 和 TextView 呢?
  • 同样的事情...您还可以设置一个复合可绘制对象,为文本视图设置动画(drawableStart、drawableEnd、drawableTop、drawableBottom)。话虽如此,我认为一个指标就足够了,为什么每个元素都需要一个指标?

标签: android android-recyclerview progress-bar android-cardview


【解决方案1】:

你可以试试这个方法

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


    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />


    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"/>
</FrameLayout>

【讨论】:

  • 如何在TextView上设置?
  • @Sushrita 将 ImageView 更改为 TextView
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-02
  • 1970-01-01
  • 2014-01-19
  • 2017-11-14
  • 2015-02-04
  • 1970-01-01
相关资源
最近更新 更多