类似AdressBar 效果的实现,地址 + 转动的图片
1. TextView 方法 :
/**
* Sets the Drawables (if any) to appear to the left of, above,
* to the right of, and below the text. Use null if you do not
* want a Drawable there. The Drawables must already have had
* {@link Drawable#setBounds} called.
*
* @attr ref android.R.styleable#TextView_drawableLeft
* @attr ref android.R.styleable#TextView_drawableTop
* @attr ref android.R.styleable#TextView_drawableRight
* @attr ref android.R.styleable#TextView_drawableBottom
*/
public void setCompoundDrawables(Drawable left, Drawable top,Drawable right, Drawable bottom) {....}
2.
AnimationDrawable
AnimationDrawable mCircularProgress = (AnimationDrawable) resources.getDrawable(R.drawable.browser_loading_anim);
TextView mtitle = new TextView();
//为TextView 右侧加Drawable .
title.setCompoundDrawables(null, null, mCircularProgress,null);
//根据动态加载进程控制图片
void setProgress(int newProgress) {
if (newProgress >= mProgress.getMax()) {
mTitle.setCompoundDrawables(null, null, null, null);
mCircularProgress.stop();
} else {
if (getWindowToken() != null) {
//注:多次调用mCircularProgress.start(),图片会不停滞,原因继续调查。
if(mCircularProgress.isRunning()) {
mTitle.setCompoundDrawables(null, null, null, null);
mCircularProgress.stop();
}
mTitle.setCompoundDrawables(null, null, mCircularProgress,null);
mCircularProgress.start();
}
}
}
3.Animation-list
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/item_1" android:duration="200" />
<item android:drawable="@drawable/item_2" android:duration="200" />
<item android:drawable="@drawable/item_3" android:duration="200" />
<item android:drawable="@drawable/item_4" android:duration="200" />
</animation-list>
以上
Consuela
20110323