android - 如何自定义进度加载器?

标签 android progressdialog loader animated-gif

我正在使用一个使用 ProgressDialog 和组件的进度加载器。 两者都是相似的类型,都是黑色的,我正在尝试更换装载机。 From this loader

我需要一个新的而不是这个进步,如下所示

Expected progress loader

最佳答案

我已经用它来处理像你这样的负载

    Dialog dialog = new Dialog(context,R.style.LoadingDialogTheme);
    dialog.setContentView(R.layout.loading);
    dialog.setCancelable(false);
    dialog.show();
    dialog.findViewById(R.id.loading_icon).startAnimation(AnimationUtils.loadAnimation(InitActivity.this, R.anim.rotate360));
    }

/res/anim/rotate360.xml

<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <rotate
        android:fromDegrees="0"
        android:toDegrees="360"
        android:pivotX="50%"
        android:pivotY="50%"
        android:duration="2000"
        android:repeatCount="infinite" />
</set>

/res/layout/loading.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:gravity="center"
  android:background="@color/loadingBackground">
  <ImageView 
    android:id="@+id/loading_icon" 
    android:gravity="center"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_loading"/>
  <TextView
    android:id="@+id/loading_text" 
    android:layout_gravity="center"
    android:text="Loading"
    android:gravity="center"
    android:textSize="18dip"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="3dip"
    android:textColor="@color/info"
    android:layout_below="@+id/loading_icon"/>
</TextView>

那么你必须做的就是拥有你的礼物的一帧,并像loading_icon.png一样使用它

祝你工作顺利:)

关于android - 如何自定义进度加载器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8590587/

相关文章:

java - 跳帧,不显示进度对话框

android - ProgressDialogs 和 Material 设计规范

javascript - jQuery 验证成功显示 gif 加载器

jquery - 图像加载时显示加载 gif

jquery - WordPress 页面加载器

android - 模拟器上按钮的颜色与实际设备不匹配

android - 使用 Rxjava Schedulers.newThread() 与 Schedulers.io() 进行改造

java - 旋转后用 ProgressBar 更新 ProgressDialog

Android通知高度和宽度

android - 读取我对象中设置的所有数据