ProgressBar 控件codeRead
来源:互联网 发布:淘宝权重低怎么办 编辑:程序博客网 时间:2024/04/30 04:25
ProgressBar sequence:
1:ProgressBar.java
1)指定attribute类型
this(context, attrs, com.android.internal.R.attr.progressBarStyle);
Attrs.xml---定义progressbar的Style属性
<attr name="progressBarStyle" format="reference" />
<attr name="progressBarStyleHorizontal" format="reference" />
<attr name="progressBarStyleSmall" format="reference" />
<attr name="progressBarStyleSmallTitle" format="reference" />
<attr name="progressBarStyleLarge" format="reference" />
<attr name="progressBarStyleInverse" format="reference" />
<attr name="progressBarStyleSmallInverse" format="reference" />
<attr name="progressBarStyleLargeInverse" format="reference" />
2)obtainStyledAttributes(attrs, R.styleable.ProgressBar, defStyle, styleRes);
Attrs.xml---定义progressbar的专有属性
<declare-styleable name="ProgressBar">
<attr name="max" format="integer" />
<attr name="progress" format="integer" />
<attr name="secondaryProgress" format="integer" />
<attr name="indeterminate" format="boolean" />
<attr name="indeterminateOnly" format="boolean" />
<attr name="indeterminateDrawable" format="reference" />
<attr name="progressDrawable" format="reference" />
<attr name="indeterminateDuration" format="integer" min="1" />
<attr name="indeterminateBehavior">
<enum name="repeat" value="1" />
<enum name="cycle" value="2" />
</attr>
<attr name="minWidth" format="dimension" />
<attr name="maxWidth" />
<attr name="minHeight" format="dimension" />
<attr name="maxHeight" />
<attr name="interpolator" format="reference" />
<attr name="animationResolution" format="integer" />
</declare-styleable>
通过Theme等对属性赋值
Theme.xml---<item name="progressBarStyle">@android:style/Widget.ProgressBar</item>
Styles.xml----
<style name="Widget.ProgressBar">
<item name="android:indeterminateOnly">true</item>
<item name="android:indeterminateDrawable">@android:drawable/progress_medium_white</item>
<item name="android:indeterminateBehavior">repeat</item>
<item name="android:indeterminateDuration">3500</item>
<item name="android:minWidth">48dip</item>
<item name="android:maxWidth">48dip</item>
<item name="android:minHeight">48dip</item>
<item name="android:maxHeight">48dip</item>
</style>
3)通过get的attribute进行处理
其中对图像的progressDrawable
在horizontal中
<style name="Widget.ProgressBar.Horizontal">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@android:drawable/progress_horizontal</item>
<item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
<item name="android:minHeight">20dip</item>
<item name="android:maxHeight">20dip</item>
</style>
@android:drawable/progress_horizontal
进入frameworks/base/core/res/res/drawable/progress_horizontal.xml,里面是对graphic属性的设置
<layer-list xmlns:android=http://schemas.android.com/apk/res/android>
<item android:id="@android:id/background">--------------这个id是ProgressBar.java中用的
<shape>//开始对background层的处理
<corners android:radius="5dip" />
<gradient
android:startColor="#ff9d9e9d"
android:centerColor="#ff5a5d5a"
android:centerY="0.75"
android:endColor="#ff747674"
android:angle="270"
/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">--------------这个id是ProgressBar.java中用的
<clip>//开始对background层的处理
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#80ffd300"
android:centerColor="#80ffb600"
android:centerY="0.75"
android:endColor="#a0ffcb00"
android:angle="270"
/>
</shape>
</clip>
</item>
</layerlist>
其中:layer-list gradient clip等属性是graphic中处理的:frameworks/base/graphics/java/android/graphics/drawable
Tips:
大部分的改动是针对graphics,drawable的
看空间里面的头文件的定义来理解
----eg:progressbar
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.Shader;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.StateListDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.graphics.drawable.shapes.
- ProgressBar 控件codeRead
- ProgressBar控件
- ProgressBar控件
- ProgressBar控件的使用
- C#progressBar控件
- android progressbar控件说明
- [控件]ProgressBar进度条
- android控件之progressbar
- Android控件之ProgressBar
- Android控件之ProgressBar
- C# ProgressBar控件
- 自定义控件之-----progressBar
- 进度条控件ProgressBar
- Android ProgressBar控件理解
- android 控件 进度条(ProgressBar)
- Android控件之ProgressBar
- 自定义控件之-----progressBar
- 自定义控件之-----progressBar
- 改写方法
- UITextField垂直居中对齐
- apxs添加apache扩展模块
- IDT系列:(二)中断处理过程,使用bochs调试IDT中的中断服务程序
- oracle - emctl start dbconsole 启动问题 (转)
- ProgressBar 控件codeRead
- android sdk安装常见问题
- HDOJ 1213 How Many Tables 杭电 ACM
- python ---简易联系人
- cocos2d-x android游戏使用自己的字体
- Linux 如何挂载windows 共享文件夹或者你的xp电脑的硬盘分区
- 汇编语言学习的一些小总结
- Hibernate中addScalar的使用
- Windbg常用命令