大牛们是怎么阅读 Android android系统源码下载的

Android系统级开发者, 喜欢vim, 苦于代码量巨大, 阅读源码和编写不是很方便, 请教大家有什么好的解决方案么? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
已注册用户请 &
Sponsored by
100offer 程序员拍卖,让不缺工作机会的优秀程序员,安全匿名的在 2 天内收到 5-10 个优质面试机会,从而拥有一份激(shou)动(ru)人(geng)心(gao)的事业。
Promoted by
Android系统级开发者, 喜欢vim, 苦于代码量巨大, 阅读源码和编写不是很方便, 请教大家有什么好的解决方案么?
09:42:25 +08:00 · 7324 次点击
这是我现在的配置
30 回复 &| &直到
21:04:58 +08:00
& & 15:47:11 +08:00
我也是做android系统开发的,一般配合openGrok来开发。读代码的时间大于写代码的时间。
& & 16:29:26 +08:00
@ 你的解决方案呢.
& & 16:31:03 +08:00
再写一段 时间就会 IDE了
& & 16:36:39 +08:00
在opengrok中查看代码,然后在vim里面修改。 基本上是这样。 看opengrok网站说有vim的插件,不过我还没有用过。
& & 16:39:45 +08:00
解决方案看这里
& & 16:40:08 +08:00
& & 17:13:02 +08:00
应用开发者想做framework开发需要怎么入门
& & 09:18:59 +08:00
工作环境觉得ide的选择。最近一年多,我要跟多个代码库打交道 [git+svn] ,多套开发环境 [3套] ,多台硬件设备 [本地有pc*2、mac os*2] 。为提升效率,我走了很多弯路。当前的解决方案:所有环境ssh打通,通过securecrt登录。ide是vim,vim配置taglist+ctags+winmanager插件,解决了ide的问题,供你参考。过程是艰难的,大概用了3天时间来配置各种插件和适应。偶尔用用vim与仅使用差异是巨大的,不过现在已经过去快一年了,感觉很值得,对效率帮助很大
& & 09:58:08 +08:00
这个有意思,回头试一下。@ 按google的说法,framework层的开发还是用eclipse@ 这个我看过,我经常在ssh的终端下工作,所以还是借助vi来实现,而且UI太丑了。@ cscope+ctags+global都试过,说实话,跳转和搜索加上代码补全,真的不及source insight,我在想如Linus那些大神是怎么做内核开发的。
& & 10:36:15 +08:00
@ linus大神对内核里面的数据结构烂熟于心了,不需要来回跳转。遇到不熟悉的直接cat + grep搞定。我们需要跳转有两种可能1. 我们阅读人家的代码, 这个对于大神来说太easy了, 他们见过很多数据结构和设计模式,所以来回跳转对他们来说是多余的。 2.自己的代码记不住了, 这一点还是提升自己的内功把。
& & 10:38:29 +08:00
@ 开源界的大神可以很轻松的把scope 移植到vim或者emacs里面,再加一个符号管理, 和buffer管理。 可见他们不需要这样的东西。还觉得麻烦。
& & 10:58:23 +08:00
@ 感谢回复,改变了我的一些想法。
& & 12:40:13 +08:00
不知道java是什么样子,我写python,代码层级很分明,模块名字也尽可能清晰。一般vim分三列,加上双屏,如果需要看代码,就在小屏幕上sublime直接打开。vim中不用tags,不用wm,打开文件直接敲文件名。由于是做游戏,所以文件比较多,一般都是几百个文件。。。。
& & 13:47:40 +08:00
@ 想请教一下,没有需求要查某个关键词么?如果不用tags和cscope的话
& & 14:02:48 +08:00
wine + source insight
& & 14:08:33 +08:00
Source Insight 3.5
& & 14:09:28 +08:00
Source Insight 3.5 用了你就知道
& & 14:11:39 +08:00
windows下用Source Insight,Mac下面 Sublime Text 2
& & 15:41:02 +08:00
目前我使用的是 Eclipse + Vrapper有一点苦恼的是,Vrapper的撤销有时候会撤销多步。
& & 17:19:01 +08:00
@ 有时候确实有这种情况。比较少见。如果遇到,直接grep解决。比较少见的原因是,代码层次非常清晰,一个关键词(结合上下文)往往只会在一层代码层出现,而出现的文件也比较有限,基本都能记住在哪里。
& & 21:04:23 +08:00
同样是Android系统开发,大概讲下我的工作环境配置:编译和开发都是ssh到服务器,服务器保证了编译速度,byobu+tmux保证了每次ssh到服务器上都保留上次的session和配置,不论从公司或家里的哪台电脑哪种系统;如果服务器关机,Teamocil可以帮我瞬间恢复开发环境,包括envsetup;编译后的image目录直接sshfs mount到本地,可通过fastboot刷机;编辑器用vim(配置了byobu和vim后,一点也不丑),除了楼上说的taglist、ctags这些基本插件,查关键词用Ack。因为我公司的Android平台很多,4.x、2.x,甚至还有1.x上的维护。我上面讲的这种开发模式的开发速度目测可以甩出在自己本地电脑上用eclipse等工具开发的同事N条街。不过上面的配置开发快,但vim读代码速度确实不如Source Insight,但是Source Insight收费而且还不跨平台所以一直没用。LS有提到OpenGrok,感谢,回头研究下……
& & 21:32:26 +08:00
@ android估计得几十万个文件,各种工程。另外 推荐你一个plugin叫ctrlp,你会爱上她的。@
轻量的搜索可以用一个叫ack的plugin@ @ @
好多同事这么干,包括做modem的,我的怨念是好好的一个android干嘛要用盗版的wine的win系软件呢。。。@ sublime做前端还行,android这种几十万文件级的不适合啊。@ 还是经常ssh到服务器编译修改代码,不习惯太重的ide@ 试试ack吧 轻量一些。
& & 21:36:30 +08:00
@ 感谢分享。由于公司还在用win系的office办公,所以离不开win环境,现在我的方案是putty+tmux+vim和一堆plugin,改自己熟悉的代码还好,否则不是很方便。快速编译你有什么好的分享么?Android编译那叫一个漫长啊。。。
& & 21:39:13 +08:00
@ 几十万个文件?同一个项目?不包括框架代码?
& & 21:43:56 +08:00
@ 是整个Android源码啊,虽说不可能同时开发所有,但系统级开发,有的时候要改驱动(kernel)有的时候要改框架层。。。so。。。
& & 22:23:30 +08:00
@ 那要这么论。就没法说了。。。。我倒是经常看django和python的源码。不过估计比你这个容易。。。。
& & 23:25:59 +08:00
@ 一个Activity.java就上万行代码,所以纠结了好久,其实也没什么好办法来解决。可能还是要调教一个好的IDE吧我想。
& & 08:02:04 +08:00 via iPhone
说下我的情况吧:两年framwork开发,第二年开始一直vim现在转做android app,依然vim以后还是vim我说的不是哪个更好,而是说一种可行性,毕竟到现在为止我还天天写代码。
& & 15:06:45 +08:00
现在完全依赖fuzzyfinder插件,以前用source insight用得最多的就是f7全局tag和C_o快速打开文件,这两个fuzzyfinder都能做到,所以平移过去没多大困难,就是看函数关联有点麻烦,cctree插件好像有问题,太大的工程读取cscope.out会失败。
& & 21:04:58 +08:00
codesearch 这个搜代码挺好用的,建立索引,搜的比较快。。/p/codesearch/
& · & 619 人在线 & 最高记录 1307 & · &
创意工作者们的社区
Lovingly made by OLIVIDA
VERSION: 3.8.3 · 50ms · UTC 09:02 · PVG 17:02 · LAX 02:02 · JFK 05:02? Do have faith in what you're doing.Android自定义控件:进度条的四种实现方式(Progress Wheel的解析)(源码 + Demo) - 推酷
Android自定义控件:进度条的四种实现方式(Progress Wheel的解析)(源码 + Demo)
Progress Wheel为GitHub热门项目,作者是:
,项目地址:
/Todd-Davies/ProgressWheel
前三种实现方式代码出自:
/openandroid//android-custom-loading/
(源码在最后)
最近一直在学习自定义控件,搜了许多大牛们Blog里分享的小教程,也上GitHub找了一些类似的控件进行学习。发现读起来都不太好懂,就想写这么一篇东西作为学习笔记吧。
一、控件介绍:
进度条在App中非常常见,例如下载进度、加载图片、打开文章、打开网页等等……都需要这么一个效果让用户知道我们的App正在读取,以构造良好的交互。如果没有这样一个效果的话,用户没法知道东西有没有下载好、图片加载了没有、文章打开了没……会让用户很不爽。基于这样的情景我们的UI设计师们创造了这样一个控件。
二、这篇文章会涉及的知识点:
跟我一样刚入门的Android菜鸟们,我推荐大家先了解一下这些知识点再往下看。这些知识点我也会推荐一些博客给大家看看,更推荐大家看文档里的解释,当然大牛们可以直接无视……
1、ClipDrawable类:能够对一个drawable类进行剪切操作(即只显示某一部分的区域,另一部分隐藏),显示多大的区域由level控制(level取值是0~10000)
【博客:http://blog.csdn.net/lonelyroamer/article/details/8244777】、没文档的可以在这看【/api/android/ClipDrawable.html】
2、自定义View:guolin大神的深入学习View四部曲
http://blog.csdn.net/guolin_blog/article/details/】
http://blog.csdn.net/guolin_blog/article/details/】
http://blog.csdn.net/guolin_blog/article/details/】
http://blog.csdn.net/guolin_blog/article/details/】
3、没看过我写的:Android自定义控件——老版优酷三级菜单的话,或许需要看看这个:
【RotateAnimation详解——】
三、Android上的实现方式:
(前三种方法比较简单,第四种方法是GitHub项目的解析,对前三种没兴趣可以直接跳到后边……)
1、效果图:
将进度条的变换过程分解为一帧一帧的图片,将这些一帧一帧的图片连起来构成一个动画。常用于:手机阅读网页、逛社区时,加载图片、文章等不需要清楚知道加载进度,但是需要知道是否进行加载的情景。
这种方法实现可以通过创建一个animation-list的XML文件,然后给系统API提供的ProgressBar的indeterminateDrawable属性就可以了。(这个属性应该是类似于设置一个动画吧……)
&?xml version=&1.0& encoding=&utf-8&?&
&animation-list xmlns:android=&/apk/res/android&
android:oneshot=&false& &
&item android:duration=&150& &
android:clipOrientation=&horizontal&
android:drawable=&@drawable/loading_01&
android:gravity=&left&/&
&item android:duration=&150& &
android:clipOrientation=&horizontal&
android:drawable=&@drawable/loading_02&
android:gravity=&left&/&
&item android:duration=&150& &
android:clipOrientation=&horizontal&
android:drawable=&@drawable/loading_03&
android:gravity=&left&/&
&item android:duration=&150& &
android:clipOrientation=&horizontal&
android:drawable=&@drawable/loading_04&
android:gravity=&left&/&
&item android:duration=&150& &
android:clipOrientation=&horizontal&
android:drawable=&@drawable/loading_05&
android:gravity=&left&/&
&item android:duration=&150& &
android:clipOrientation=&horizontal&
android:drawable=&@drawable/loading_06&
android:gravity=&left&/&
&item android:duration=&150& &
android:clipOrientation=&horizontal&
android:drawable=&@drawable/loading_07&
android:gravity=&left&/&
&item android:duration=&150& &
android:clipOrientation=&horizontal&
android:drawable=&@drawable/loading_08&
android:gravity=&left&/&
&item android:duration=&150& &
android:clipOrientation=&horizontal&
android:drawable=&@drawable/loading_09&
android:gravity=&left&/&
&item android:duration=&150& &
android:clipOrientation=&horizontal&
android:drawable=&@drawable/loading_10&
android:gravity=&left&/&
&item android:duration=&150& &
android:clipOrientation=&horizontal&
android:drawable=&@drawable/loading_11&
android:gravity=&left&/&
&item android:duration=&150& &
android:clipOrientation=&horizontal&
android:drawable=&@drawable/loading_12&
android:gravity=&left&/&
&/animation-list&
&ProgressBar
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:indeterminateDrawable=&@drawable/progressbar1&
2 、效果图:
在上一篇有关自定义控件的博客里我们使用了一个RotateAnimation类来实现旋转效果 (http://blog.csdn.net/u/article/details/),其实,我们在这里也可以把一张图片,通过旋转,达到我们要的效果。本质上和上一种方法没多大区别。
我们只需要创建一个rotate的XML,对其属性进行一些简单的设置,然后加入我们要用的图片就可以了。
&?xml version=&1.0& encoding=&utf-8&?&
&rotate xmlns:android=&/apk/res/android&
android:pivotX=&50%&
android:pivotY=&50%&
android:fromDegrees=&0&
android:toDegrees=&360&
android:interpolator=&@android:anim/accelerate_decelerate_interpolator& &
android:antialias=&true&
android:filter=&true&
android:src=&@drawable/loading_360&/&
&ProgressBar
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:indeterminateDrawable=&@drawable/progressbar2&/&
3、效果图:
我们可以弄两张照片,第一张是纯黑色的,然后把这张照片中心挖一个圆出来,圆区域弄成白色,挖出来的圆弄成第二张照片。我们不妨叠加显示两张照片,刚开始把第二张完全“遮住”,随着加载进度的增加,我们减少遮住的区域把第二张照片慢慢的显示出来。
Android 上刚好就有这么一个ClipDrawable类,能够实现剪裁的过程。我们来看看怎么通过这样的方式自定义一个进度条控件。
public class MyProgressBar extends FrameLayout{
private int progress = 0;
private static final int MAX_PROGRESS = 10000;
private ClipD
private Handler handler = new Handler(){
public void handleMessage(android.os.Message msg) {
if(msg.what == 0x123)
clip.setLevel(progress);
public MyProgressBar(Context context){
this(context,null,0);
public MyProgressBar(Context context,AttributeSet attrs){
this(context,null,0);
public MyProgressBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
Init(context);
public void Init(Context context){
View view = LayoutInflater.from(context).inflate(R.layout.view, null);
ImageView iv = (ImageView)view.findViewById(R.id.progress_img);
addView(view);
clip = (ClipDrawable)iv.getDrawable();
Thread thread = new Thread(new Runnable() {
public void run() {
while(running){
handler.sendEmptyMessage(0x123);
if(progress == MAX_PROGRESS)
progress = 0;
progress += 100;
Thread.sleep(18);
} catch (InterruptedException e) {
e.printStackTrace();
thread.start();
public void stop(){
progress = 0;
通过代码我们可以看到,逻辑非常简单,关键就在于ClipDrawable的setLevel()方法,这个是设置剪裁效果的。
4、效果图:
实现一个View的子类——Progress Wheel类,实现进度条效果。具体的内容我都写在了注释上,如果不了解自定义控件的知识,可以去阅读guolin博客里自定义View四部曲的讲解,讲的挺好的。
public class ProgressWheel extends View {
//绘制View用到的各种长、宽带大小
private int layout_height = 0;
private int layout_width = 0;
private int fullRadius = 100;
private int circleRadius = 80;
private int barLength = 60;
private int barWidth = 20;
private int rimWidth = 20;
private int textSize = 20;
private float contourSize = 0;
//与页边的间距
private int paddingTop = 5;
private int paddingBottom = 5;
private int paddingLeft = 5;
private int paddingRight = 5;
//View要绘制的颜色
private int barColor = 0xAA000000;
private int contourColor = 0xAA000000;
private int circleColor = 0x;
private int rimColor = 0xAADDDDDD;
private int textColor = 0xFF000000;
//绘制要用的画笔
private Paint barPaint = new Paint();
private Paint circlePaint = new Paint();
private Paint rimPaint = new Paint();
private Paint textPaint = new Paint();
private Paint contourPaint = new Paint();
//绘制要用的矩形
@SuppressWarnings(&unused&)
private RectF rectBounds = new RectF();
private RectF circleBounds = new RectF();
private RectF circleOuterContour = new RectF();
private RectF circleInnerContour = new RectF();
//每次绘制要移动的像素数目
private int spinSpeed = 2;
//绘制过程的时间间隔
private int delayMillis = 0;
int progress = 0;
boolean isSpinning =
private String text = &&;
private String[] splitText = {};
* ProgressWheel的构造方法
* @param context
* @param attrs
public ProgressWheel(Context context, AttributeSet attrs) {
super(context, attrs);
parseAttributes(context.obtainStyledAttributes(attrs,
R.styleable.ProgressWheel));
//----------------------------------
//初始化一些元素
//----------------------------------
* 调用这个方法时,使View绘制为方形
* From: //creating-custom-android-views-part-4-measuring-and-how-to-force-a-view-to-be-square/
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// 首先我们要调用超类的onMeasure借口
// 原因是我们自己去实现一个方法获得长度、宽度太麻烦了
// 使用超类的的方法非常方便而且让复杂的细节可控
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// 在这里我们不能使用getWidth()和getHeight()。
// 因为这两个方法只能在View的布局完成后才能使用,而一个View的绘制过程是先绘制元素,再绘制Layout
// 所以我们必须使用getMeasuredWidth()和getMeasuredHeight()
int size = 0;
int width = getMeasuredWidth();
int height = getMeasuredHeight();
int widthWithoutPadding = width - getPaddingLeft() - getPaddingRight();
int heigthWithoutPadding = height - getPaddingTop() - getPaddingBottom();
// 最后我们用一些简单的逻辑去计算View的大小并调用setMeasuredDimension()去设置View的大小
// 在比较View的长宽前我们不考虑间距,但当我们设置View所需要绘制的面积时,我们要考虑它
// 不考虑间距的View(View内的实际画面)此时就应该是方形的,但是由于间距的存在,最终View所占的面积可能不是方形的
if (widthWithoutPadding & heigthWithoutPadding) {
size = heigthWithoutP
size = widthWithoutP
// 如果你重写了onMeasure()方法,你必须调用setMeasuredDimension()方法
// 这是你设置View大小的唯一途径
// 如果你不调用setMeasuredDimension()方法,父控件会抛出异常,并且程序会崩溃
// 如果我们使用了超类的onMeasure()方法,我们就不是那么需要setMeasuredDimension()方法
// 然而,重写onMeasure()方法是为了改变既有的绘制流程,所以我们必须调用setMeasuredDimension()方法以达到我们的目的
setMeasuredDimension(size + getPaddingLeft() + getPaddingRight(), size + getPaddingTop() + getPaddingBottom());
* 使用onSizeChanged方法代替onAttachedToWindow获得View的面积
* 因为这个方法会在测量了MATCH_PARENT和WRAP_CONTENT后马上被调用
* 使用获得的面积设置View
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
// Share the dimensions
layout_width =
layout_height =
setupBounds();
setupPaints();
invalidate();
* 设置我们想要绘制的progress wheel的颜色
private void setupPaints() {
barPaint.setColor(barColor);
barPaint.setAntiAlias(true);
barPaint.setStyle(Style.STROKE);
barPaint.setStrokeWidth(barWidth);
rimPaint.setColor(rimColor);
rimPaint.setAntiAlias(true);
rimPaint.setStyle(Style.STROKE);
rimPaint.setStrokeWidth(rimWidth);
circlePaint.setColor(circleColor);
circlePaint.setAntiAlias(true);
circlePaint.setStyle(Style.FILL);
textPaint.setColor(textColor);
textPaint.setStyle(Style.FILL);
textPaint.setAntiAlias(true);
textPaint.setTextSize(textSize);
contourPaint.setColor(contourColor);
contourPaint.setAntiAlias(true);
contourPaint.setStyle(Style.STROKE);
contourPaint.setStrokeWidth(contourSize);
* 设置元素的边界
private void setupBounds() {
// 为了保持宽度和长度的一致,我们要获得layout_width和layout_height中较小的一个,从而绘制一个圆
int minValue = Math.min(layout_width, layout_height);
// 计算在绘制过程中在x,y方向的偏移量
int xOffset = layout_width - minV
int yOffset = layout_height - minV
// 间距加上偏移量
paddingTop = this.getPaddingTop() + (yOffset / 2);
paddingBottom = this.getPaddingBottom() + (yOffset / 2);
paddingLeft = this.getPaddingLeft() + (xOffset / 2);
paddingRight = this.getPaddingRight() + (xOffset / 2);
int width = getWidth(); //this.getLayoutParams().
int height = getHeight(); //this.getLayoutParams().
rectBounds = new RectF(paddingLeft,
paddingTop,
width - paddingRight,
height - paddingBottom);
circleBounds = new RectF(paddingLeft + barWidth,
paddingTop + barWidth,
width - paddingRight - barWidth,
height - paddingBottom - barWidth);
circleInnerContour = new RectF(circleBounds.left + (rimWidth / 2.0f) + (contourSize / 2.0f), circleBounds.top + (rimWidth / 2.0f) + (contourSize / 2.0f), circleBounds.right - (rimWidth / 2.0f) - (contourSize / 2.0f), circleBounds.bottom - (rimWidth / 2.0f) - (contourSize / 2.0f));
circleOuterContour = new RectF(circleBounds.left - (rimWidth / 2.0f) - (contourSize / 2.0f), circleBounds.top - (rimWidth / 2.0f) - (contourSize / 2.0f), circleBounds.right + (rimWidth / 2.0f) + (contourSize / 2.0f), circleBounds.bottom + (rimWidth / 2.0f) + (contourSize / 2.0f));
fullRadius = (width - paddingRight - barWidth) / 2;
circleRadius = (fullRadius - barWidth) + 1;
* 从XML中解析控件的属性
* @param a the attributes to parse
private void parseAttributes(TypedArray a) {
barWidth = (int) a.getDimension(R.styleable.ProgressWheel_barWidth,
barWidth);
rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_rimWidth,
rimWidth);
spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_spinSpeed,
spinSpeed);
delayMillis = a.getInteger(R.styleable.ProgressWheel_delayMillis,
delayMillis);
if (delayMillis & 0) {
delayMillis = 0;
barColor = a.getColor(R.styleable.ProgressWheel_barColor, barColor);
barLength = (int) a.getDimension(R.styleable.ProgressWheel_barLength,
barLength);
textSize = (int) a.getDimension(R.styleable.ProgressWheel_textSize,
textSize);
textColor = (int) a.getColor(R.styleable.ProgressWheel_textColor,
textColor);
//如果text是空的,就无视它
if (a.hasValue(R.styleable.ProgressWheel_text)) {
setText(a.getString(R.styleable.ProgressWheel_text));
rimColor = (int) a.getColor(R.styleable.ProgressWheel_rimColor,
rimColor);
circleColor = (int) a.getColor(R.styleable.ProgressWheel_circleColor,
circleColor);
contourColor = a.getColor(R.styleable.ProgressWheel_contourColor, contourColor);
contourSize = a.getDimension(R.styleable.ProgressWheel_contourSize, contourSize);
// 使用TypedArray获得控件属性时必须要注意:使用结束后必须回收TypedArray的对象
a.recycle();
//----------------------------------
//----------------------------------
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//绘制内圆
canvas.drawArc(circleBounds, 360, 360, false, circlePaint);
//绘制边界
canvas.drawArc(circleBounds, 360, 360, false, rimPaint);
canvas.drawArc(circleOuterContour, 360, 360, false, contourPaint);
canvas.drawArc(circleInnerContour, 360, 360, false, contourPaint);
//绘制条纹
if (isSpinning) {
canvas.drawArc(circleBounds, progress - 90, barLength, false,
barPaint);
canvas.drawArc(circleBounds, -90, progress, false, barPaint);
//绘制我们想要设置的文字 (并让它显示在圆水平和垂直方向的中心处)
float textHeight = textPaint.descent() - textPaint.ascent();
float verticalTextOffset = (textHeight / 2) - textPaint.descent();
for (String s : splitText) {
float horizontalTextOffset = textPaint.measureText(s) / 2;
canvas.drawText(s, this.getWidth() / 2 - horizontalTextOffset,
this.getHeight() / 2 + verticalTextOffset, textPaint);
if (isSpinning) {
scheduleRedraw();
private void scheduleRedraw() {
progress += spinS
if (progress & 360) {
progress = 0;
postInvalidateDelayed(delayMillis);
判断wheel是否在旋转
public boolean isSpinning() {
if(isSpinning){
* 重设进度条的值
public void resetCount() {
progress = 0;
setText(&0%&);
invalidate();
* 停止进度条的旋转
public void stopSpinning() {
isSpinning =
progress = 0;
postInvalidate();
* 让进度条开启旋转模式
public void spin() {
isSpinning =
postInvalidate();
* 让进度条每次增加1(最大值为360)
public void incrementProgress() {
isSpinning =
progress++;
if (progress & 360)
progress = 0;
setText(Math.round(((float) progress / 360) * 100) + &%&);
postInvalidate();
* 设置进度条为一个确切的数值
public void setProgress(int i) {
isSpinning =
progress =
postInvalidate();
//----------------------------------
//get和set方法
//----------------------------------
* 设置progress bar的文字并不需要刷新View
* @param text the text to show ('\n' constitutes a new line)
public void setText(String text) {
this.text =
splitText = this.text.split(&\n&);
public int getCircleRadius() {
return circleR
public void setCircleRadius(int circleRadius) {
this.circleRadius = circleR
public int getBarLength() {
return barL
public void setBarLength(int barLength) {
this.barLength = barL
public int getBarWidth() {
return barW
public void setBarWidth(int barWidth) {
this.barWidth = barW
if ( this.barPaint != null ) {
this.barPaint.setStrokeWidth( this.barWidth );
public int getTextSize() {
return textS
public void setTextSize(int textSize) {
this.textSize = textS
if ( this.textPaint != null ) {
this.textPaint.setTextSize( this.textSize );
public int getPaddingTop() {
return paddingT
public void setPaddingTop(int paddingTop) {
this.paddingTop = paddingT
public int getPaddingBottom() {
return paddingB
public void setPaddingBottom(int paddingBottom) {
this.paddingBottom = paddingB
public int getPaddingLeft() {
return paddingL
public void setPaddingLeft(int paddingLeft) {
this.paddingLeft = paddingL
public int getPaddingRight() {
return paddingR
public void setPaddingRight(int paddingRight) {
this.paddingRight = paddingR
public int getBarColor() {
return barC
public void setBarColor(int barColor) {
this.barColor = barC
if ( this.barPaint != null ) {
this.barPaint.setColor( this.barColor );
public int getCircleColor() {
return circleC
public void setCircleColor(int circleColor) {
this.circleColor = circleC
if ( this.circlePaint != null ) {
this.circlePaint.setColor( this.circleColor);
public int getRimColor() {
return rimC
public void setRimColor(int rimColor) {
this.rimColor = rimC
if ( this.rimPaint != null ) {
this.rimPaint.setColor( this.rimColor );
public Shader getRimShader() {
return rimPaint.getShader();
public void setRimShader(Shader shader) {
this.rimPaint.setShader(shader);
public int getTextColor() {
return textC
public void setTextColor(int textColor) {
this.textColor = textC
if ( this.textPaint != null ) {
this.textPaint.setColor( this.textColor );
public int getSpinSpeed() {
return spinS
public void setSpinSpeed(int spinSpeed) {
this.spinSpeed = spinS
public int getRimWidth() {
return rimW
public void setRimWidth(int rimWidth) {
this.rimWidth = rimW
if ( this.rimPaint != null ) {
this.rimPaint.setStrokeWidth( this.rimWidth );
public int getDelayMillis() {
return delayM
public void setDelayMillis(int delayMillis) {
this.delayMillis = delayM
public int getContourColor() {
return contourC
public void setContourColor(int contourColor) {
this.contourColor = contourC
if ( contourPaint != null ) {
this.contourPaint.setColor( this.contourColor );
public float getContourSize() {
return this.contourS
public void setContourSize(float contourSize) {
this.contourSize = contourS
if ( contourPaint != null ) {
this.contourPaint.setStrokeWidth( this.contourSize );
已发表评论数()
&&登&&&陆&&
已收藏到推刊!
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见

我要回帖

更多关于 android订餐系统源码 的文章

 

随机推荐