티스토리 뷰

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);
반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/08   »
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
글 보관함
반응형