BÀI 62 - THIẾT KẾ PROGRESS BAR HIỂN THỊ DỮ LIỆU TRONG ANDROID
Tạo một style như thế này:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Namestyle" >
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@drawable/progressbar_display_data</item>
</style>
</resources>
Thiết kế progress bar như thế này
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:shape="ring"
android:thicknessRatio="10"
android:useLevel="false"
tools:ignore="ExtraText">
<solid android:color="#D6D6D6"/>
</shape>
</item>
<item>
<rotate
android:fromDegrees="270"
android:toDegrees="270" >
<shape
android:shape="ring"
android:thicknessRatio="10"
android:useLevel="true" >
<gradient
android:startColor="#76FF03"
android:endColor="#FF3D00"
android:type="sweep" />
</shape>
</rotate>
</item>
</layer-list>
Thiết kế progress bar trong xml như thế này
<ProgressBar
style="@style/Namestyle"
android:progressDrawable="@drawable/thietKeCuaProgressBar"
tools:progress="60"
android:layout_width="140dp"
android:layout_height="140dp"/>
Trong java set mức cho progress bar từ 0 đến 100.
progressBar.setProgress((int));
progressBar.setProgress((int));
progressBar.setProgress((int));