Android
[Android] Circular ProgressBar 설정
EnvEng10
2020. 10. 19. 10:31
반응형
1. drawable/circle_progressbar 을 만들어주자
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360">
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="8"
android:useLevel="false">
<size
android:width="76dp"
android:height="76dp"/>
<gradient
android:angle="0"
android:endColor="@color/selected_color"
android:startColor="@color/transparent"
android:type="sweep"
android:useLevel="false"/>
</shape>
</rotate>
2. progressbar 설정
android:indeterminateDuration="1000" 원이 돌아가는 속도값
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:clickable="true"
android:background="@color/function_fragment_bg"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:visibility="gone"
android:layout_centerInParent="true"
android:indeterminateDrawable="@drawable/circle_progress"
android:indeterminateDuration="1000"
android:id="@+id/agree_progress_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
3. View 설정
visible, gone, invisible 을 활용하여 사용
private ProgressBar progressBar;
progressBar = v.findViewById(R.id.progress_bar);
progressBar.setVisibility(View.VISIBLE);
반응형