【问题标题】:Custom circular ProgressBar with image in center [closed]图像居中的自定义圆形 ProgressBar [关闭]
【发布时间】:2015-03-24 09:54:07
【问题描述】:

对于我的 android 应用程序,我想将图像放入 circular progress bar。 预期设计:

http://hpics.li/cd6acba

关于如何做到这一点的任何想法?

【问题讨论】:

    标签: android progressdialog


    【解决方案1】:
    1. 创建动画 xml:

      <?xml version="1.0" encoding="utf-8"?>
      <animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
          android:drawable="@drawable/progress_bar"
          android:pivotX="50%"
          android:pivotY="50%" />
      
    2. 在布局 xml 中为进度条视图设置以下内容:

      android:indeterminateDrawable="@animator/progressbar_animation"
      

    【讨论】:

      【解决方案2】:

      你可以取一个普通的布局文件: loader.xml

      <?xml version="1.0" encoding="utf-8"?>
      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:gravity="center"
          android:clickable="false">
      
          <ProgressBar
              android:id="@+id/progressBar1"
              style="@android:style/Widget.ProgressBar.Small.Inverse"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:indeterminate="true"
              android:layout_centerInParent="true"
              android:padding="30dp"
              android:clickable="false"/>
      
          <ImageView
              android:id="@+id/textView1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_centerInParent="true"
              android:src="@drawable/img"
              android:clickable="false"/>
      
      </RelativeLayout>
      

      根据你的设计做一些小调整。

      现在使用这个布局作为你的进度对话框drawable。

      【讨论】:

      • 开始标签是RelativeLayout,而结束标签是LinearLayout。我认为这不会编译。
      • 不错的收获。已修改代码。 @Sriram
      猜你喜欢
      • 2017-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-11
      • 2015-01-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多