类似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
分享到:
相关推荐
3、TextView.setCompoundDrawables(left, top, right, bottom) 1、TextView使用ImageSpan显示图片 ImageSpan span = new ImageSpan(this, R.drawable.ic_launcher); SpannableString spanStr = new SpannableString...
textView.setCompoundDrawables(null, null, imageDraw, null); } ``` 这里的`getMinimumWidth()`和`getMinimumHeight()`用于获取Drawable的最小尺寸,确保它在文本周围正确显示。`setCompoundDrawables()`方法...
- `Drawable`可以与`View`的`setCompoundDrawables()`方法结合,用于设置TextView左右两侧的图标。 3. **Nine-Patch Drawable**: 这是一种特殊的位图`Drawable`,允许开发者指定图像的可拉伸区域和不变区域,以便...
3、TextView.setCompoundDrawables(left, top, right, bottom) 1、TextView使用ImageSpan显示图片 ImageSpan span = new ImageSpan(this, R.drawable.ic_launcher); SpannableString spanStr = new Spannab
- **setCompoundDrawables()**:设置在文本四周的Drawable资源,以及它们的边界。 ### 其他控件简介 除了TextView之外,文档中还提到了一些其他控件: - **Button**:用于创建按钮,可以响应用户的点击事件。 - *...
- **`setCompoundDrawables()`**:设置图像的位置,需先调用`setBounds(Rect)`。 - **`setCompoundDrawablesWithIntrinsicBounds()`**:设置图像位置,但保持图像原始边界不变。 - **`setPadding()`**:根据位置设置...
在自定义的`Toolbar`中,通过`findViewById()`找到预设的`TextView`控件,然后提供一系列的公共方法来设置它们的属性。这样,我们就可以在各个界面根据需求直接调用这些方法,实现快速定制`ToolBar`的样式,而无需...
| `setCompoundDrawables()` | 设置图像显示的位置,在设置该 Drawable 资源之前需要调用 `setBounds(Rect)` | void | | `setCompoundDrawablesWithIntrinsicBounds()` | 设置 Drawable 图像的显示位置,但其边界...
- **setCompoundDrawables()**:设置文本前后左右的图标或图片。 - **setCompoundDrawablesWithIntrinsicBounds()**:设置图标的位置,但保持图标原始大小不变。 - **setPadding()**:设置四周的内边距。 - **...