create android battery widget animated when charging -
i want create battery animated widget when battery charging.i want show images continuously. use imageview
below:
<imageview android:id="@+id/batterycharging_anim" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_centerhorizontal="true" android:src="@anim/batterycharging" />
and batterycharging anim file below:
<?xml version="1.0" encoding="utf-8"?> <animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/battery_c_10" android:duration="25" /> <item android:drawable="@drawable/battery_c_20" android:duration="25" /> <item android:drawable="@drawable/battery_c_30" android:duration="25" /> <item android:drawable="@drawable/battery_c_40" android:duration="25" /> <item android:drawable="@drawable/battery_c_50" android:duration="25" /> <item android:drawable="@drawable/battery_c_60" android:duration="25" /> <item android:drawable="@drawable/battery_c_70" android:duration="25" /> <item android:drawable="@drawable/battery_c_80" android:duration="25" /> <item android:drawable="@drawable/battery_c_90" android:duration="25" /> <item android:drawable="@drawable/battery_c_100" android:duration="25" /> </animation-list>
and here method updating widget:
private remoteviews buildupdate(context context) { remoteviews widgetview = new remoteviews(this.getpackagename(), r.layout.batterywidget_layout); if(status== batterymanager.battery_status_charging) { } }
what should next? should put in if block??
i think basic implementation this
updated:
found out can't use animation in remoteviews. can use progressbar in layout , set android:indeterminatedrawable animation , make visible , invisible according battery status
Comments
Post a Comment