๋ฐ์ํ
์ํ ํ๋ก๊ทธ๋ ์ค๋ฐ ์ฌ์ฉ๋ฒ๊ณผ ๊ทธ๋ผ๋ฐ์ด์
ํจ๊ณผ ์ ์ฉ ๋ฐ ์ปฌ๋ฌ ๋ณ๊ฒฝ๋ฐฉ๋ฒ์
๋๋ค.
์ ๊ฐ ์ฌ์ฉํ ๋ฐฉ๋ฒ์ ์ํ ํ๋ก๊ทธ๋ ์ค๋ฐ๋ฅผ RelativeLayout์ผ๋ก ๋ ํ๋ก๊ทธ๋ ์ค๋ฐ๋ฅผ ๊ฒน์ณ ์ฌ์ฉํ๋ ๋ฐฉ์์
๋๋ค.
์ฐ์ res -> drawable์ 2๊ฐ์ง xml์ ์์ฑํฉ๋๋ค.
<circular_progress_background.xml>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/progress">
<rotate
android:fromDegrees="270"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="270" >
<shape
android:innerRadius="64dp"
android:useLevel="true"
android:shape="ring"
android:thickness="10dp" >
<gradient
android:centerColor="@color/color_ffffff"
android:endColor="@color/color_ffffff"
android:startColor="@color/color_ffffff"
android:type="sweep" />
</shape>
</rotate>
</item>
</layer-list>
<circular_progress_foreground.xml>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/progress">
<rotate
android:fromDegrees="270"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="270" >
<shape
android:innerRadius="64dp"
android:useLevel="true"
android:shape="ring"
android:thickness="10dp" >
<gradient
android:startColor="@color/color_edf436"
android:endColor="@color/color_3aedf4"
android:type="sweep" />
</shape>
</rotate>
</item>
</layer-list>
android:startColor, android:endColor, android:centerColo๋ก ๊ทธ๋ผ๋ฐ์ด์
ํจ๊ณผ๋ฅผ ์ ์ฉํ ์ ์์ต๋๋ค
๊ทธ ๋ค์ res -> layout ํด๋์ xml ํ์ผ ํ๋๋ฅผ ์์ฑํฉ๋๋ค.
<activityCircularProgressbar.xml>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp" >
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="148dp"
android:layout_height="148dp"
android:layout_centerInParent="true"
android:indeterminate="false"
android:progress="100"
android:progressDrawable="@drawable/circular_progress_background" />
<ProgressBar
android:id="@+id/cpb"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="148dp"
android:layout_height="148dp"
android:layout_centerInParent="true"
android:indeterminate="false"
android:progressDrawable="@drawable/circular_progress_foreground" />
</RelativeLayout>
[๊ฒฐ๊ณผ ํ๋ฉด]