Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- JavaScript
- Android
- plugin
- mapreduce
- MSSQL
- R
- es6
- Python
- Java
- GIT
- xPlatform
- NPM
- 공정능력
- table
- window
- Eclipse
- Sqoop
- tomcat
- mybatis
- 보조정렬
- react
- SPC
- IntelliJ
- SSL
- SQL
- Express
- Kotlin
- vaadin
- Spring
- hadoop
Archives
- Today
- Total
DBILITY
android loading indicator example 본문
반응형
ProgressBar progressBar = new ProgressBar(this);
progressBar.getIndeterminateDrawable().mutate().setTintList(ColorStateList.valueOf(Color.RED));
Dialog progressDialog = new Dialog(this);
progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
progressDialog.setContentView(progressBar);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setOnCancelListener(
new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
dialog.dismiss();
}
});
또는
ContentLoadingProgressBar 사용시
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.ContentLoadingProgressBar
android:id="@+id/pb_loading"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:indeterminateTint="#E91E63"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
public class LoadingDialog {
private static Dialog dialog;
public static void show(@NonNull Context context) {
dialog = new Dialog(context);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.setContentView(R.layout.dialog_loading);
dialog.setCanceledOnTouchOutside(false);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
dialog.dismiss();
}
});
dialog.show();
}
public static synchronized void hide() {
if (dialog != null) {
dialog.dismiss();
dialog = null;
}
}
}
또는
ProgressIndicator 사용시 layout
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.material.progressindicator.CircularProgressIndicator
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
app:indicatorColor="#FF0000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
반응형
'android > java' 카테고리의 다른 글
android ANR, Thread, Handler, runOnUiThread, View Handler, AsyncTask, RxJava, Callback Interface (0) | 2024.05.23 |
---|---|
android downloded apk file version check and install (0) | 2024.05.09 |
WindowMetrics 화면 크기 등 (0) | 2024.05.04 |
android shortcut (0) | 2024.05.02 |
android.nonFinalResIds=false (0) | 2024.04.17 |
Comments