Google이 제공 한 제한된 문서를 읽으면 ProgressBar / ProgressDialog의 모양을 DrawBar의 style 속성에 할당하여 새 스타일을 만들면 간단하게 변경할 수 있습니다. 그러나 이것이 제대로 작동하도록 할 수는 없습니다. 여기까지 내가 한 일이 있습니다.
이런 모양을 만들었습니다 (mp2.xml)
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:innerRadiusRatio="4"
android:thicknessRatio="4"
android:useLevel="false">
<size android:width="50dip" android:height="50dip" />
<gradient android:type="sweep" android:useLevel="false" android:startColor="#300000ff" android:centerColor="#500000ff" android:endColor="#ff0000ff" />
</shape>
다음과 같이 애니메이션 (mp3.xml)을 만들었습니다.
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0" android:toDegrees="30" android:repeatCount="1" />
</item>
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="30" android:toDegrees="60" android:repeatCount="1" />
</item>
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="60" android:toDegrees="90" android:repeatCount="1" />
</item>
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="90" android:toDegrees="120" android:repeatCount="1" />
</item>
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="120" android:toDegrees="150" android:repeatCount="1" />
</item>
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="150" android:toDegrees="180" android:repeatCount="1" />
</item>
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="180" android:toDegrees="210" android:repeatCount="1" />
</item>
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="210" android:toDegrees="240" android:repeatCount="1" />
</item>
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="240" android:toDegrees="270" android:repeatCount="1" />
</item>
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="270" android:toDegrees="300" android:repeatCount="1" />
</item>
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="300" android:toDegrees="330" android:repeatCount="1" />
</item>
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="330" android:toDegrees="360" android:repeatCount="1" />
</item>
</animation-list>
그런 다음 다음과 같은 스타일 (attrs.xml)을 작성했습니다.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style parent="@android:style/Widget.ProgressBar" name="customProgressBar">
<item name="android:progressDrawable">@anim/mp3</item>
</style>
</resources>
내 main.xml에서 다음과 같이 스타일을 설정했습니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:drawingCacheQuality="high">
<ProgressBar android:id="@+id/ProgressBar01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" style="@style/customProgressBar"/>
</LinearLayout>
그러나 여전히 이전과 동일한 드로어 블을 보여줍니다. 내가 뭘 잘못하고 있죠?