`
consuela.zhao
  • 浏览: 23786 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

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

分享到:
评论

相关推荐

    TextView显示图片

    3、TextView.setCompoundDrawables(left, top, right, bottom) 1、TextView使用ImageSpan显示图片 ImageSpan span = new ImageSpan(this, R.drawable.ic_launcher); SpannableString spanStr = new SpannableString...

    View的drawable的使用

    textView.setCompoundDrawables(null, null, imageDraw, null); } ``` 这里的`getMinimumWidth()`和`getMinimumHeight()`用于获取Drawable的最小尺寸,确保它在文本周围正确显示。`setCompoundDrawables()`方法...

    安卓开发-drawable(图片).zip.zip

    - `Drawable`可以与`View`的`setCompoundDrawables()`方法结合,用于设置TextView左右两侧的图标。 3. **Nine-Patch Drawable**: 这是一种特殊的位图`Drawable`,允许开发者指定图像的可拉伸区域和不变区域,以便...

    Android中TextView显示插入的图片实现方法

    3、TextView.setCompoundDrawables(left, top, right, bottom) 1、TextView使用ImageSpan显示图片 ImageSpan span = new ImageSpan(this, R.drawable.ic_launcher); SpannableString spanStr = new Spannab

    Android中常见控件的介绍和使用.pdf

    - **setCompoundDrawables()**:设置在文本四周的Drawable资源,以及它们的边界。 ### 其他控件简介 除了TextView之外,文档中还提到了一些其他控件: - **Button**:用于创建按钮,可以响应用户的点击事件。 - *...

    Android中常见控件的介绍和使用

    - **`setCompoundDrawables()`**:设置图像的位置,需先调用`setBounds(Rect)`。 - **`setCompoundDrawablesWithIntrinsicBounds()`**:设置图像位置,但保持图像原始边界不变。 - **`setPadding()`**:根据位置设置...

    Android ToolBar整合实例使用方法详解

    在自定义的`Toolbar`中,通过`findViewById()`找到预设的`TextView`控件,然后提供一系列的公共方法来设置它们的属性。这样,我们就可以在各个界面根据需求直接调用这些方法,实现快速定制`ToolBar`的样式,而无需...

    android GUI

    | `setCompoundDrawables()` | 设置图像显示的位置,在设置该 Drawable 资源之前需要调用 `setBounds(Rect)` | void | | `setCompoundDrawablesWithIntrinsicBounds()` | 设置 Drawable 图像的显示位置,但其边界...

    android常用控件

    - **setCompoundDrawables()**:设置文本前后左右的图标或图片。 - **setCompoundDrawablesWithIntrinsicBounds()**:设置图标的位置,但保持图标原始大小不变。 - **setPadding()**:设置四周的内边距。 - **...

Global site tag (gtag.js) - Google Analytics