Drawable & DrawableAnimation & Textview.setCompoundDrawables

类似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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值