реализация Custom ProgressBar
Добавлено: 14 ноя 2012, 12:37
Разрабатываю приложение в нем есть элемент который отображает процент батареи. Хочу сделать ProgressBar который будет отображать прогресс как на картинке ниже. Как я понимаю нужно сделать animation-list и указать у стандартного ProgressBar параметр android:indeterminateDrawable. Не могу понять как будет происходить изменение состояния ProgressBar и как это реализовать.

animation-list

animation-list
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:duration="1000">
<scale
android:drawable="@drawable/percent25"
android:scaleGravity="center" />
</item>
<item android:duration="1000">
<scale
android:drawable="@drawable/percent50"
android:scaleGravity="center" />
</item>
<item android:duration="1000">
<scale
android:drawable="@drawable/percent75"
android:scaleGravity="center" />
</item>
<item android:duration="1000">
<scale
android:drawable="@drawable/percent100"
android:scaleGravity="center" />
</item>
</animation-list>
Код: Выделить всё
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="84dp"
android:layout_marginTop="90dp"
android:indeterminateDrawable="@drawable/custom_progress" />
</RelativeLayout>