Android的ProgressHUD多種加載效果:KProgressHUD

jopen 8年前發布 | 73K 次閱讀 Android開發 移動開發

Android的ProgressHUD,多種加載效果。類似于ios中的MBProgressHUD, SVProgressHUD。

使用說明:

Gradle

build.gradle

dependencies {
    // Other dependencies
    compile 'com.kaopiz:kprogresshud:1.0.1'
}

Indeterminate HUD

KProgressHUD.create(MainActivity.this)
    .setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
    .setLabel("Please wait")
    .setDetailsLabel("Downloading data");
    .setCancellable(true)
    .setAnimationSpeed(2)
    .setDimAmount(0.5f)
    .show();

Determinate HUD

KProgressHUD hud = KProgressHUD.create(MainActivity.this)
                    .setStyle(KProgressHUD.Style.ANNULAR_DETERMINATE)
                    .setLabel("Please wait")
                    .setMaxProgress(100)
                    .show();
hud.setProgress(90);

你還可以提供一個自定義的View讓HUD顯示

ImageView imageView = new ImageView(this);
imageView.setImageResource(R.mipmap.ic_launcher);KProgressHUD.create(MainActivity.this)
    .setCustomView(imageView)
    .setLabel("This is a custom view")
    .show();

這個自定義的View可以實現Determinate或者Indeterminate,這樣HUD就把這個view視作默認的determinate 或者 indeterminate實現,  但這不是必須。

See Javadocs or sample app for more information.


項目地址: https://github.com/Kaopiz/KProgressHUD

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!