Chinaunix首页 | 论坛 | 博客
  • 博客访问: 876008
  • 博文数量: 478
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 4832
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-28 11:12
文章分类

全部博文(478)

文章存档

2019年(1)

2018年(27)

2017年(21)

2016年(171)

2015年(258)

我的朋友

分类: Android平台

2016-05-31 11:18:51

1. 参考文档
http://blog.csdn.net/u010223349/article/details/40392789
2. 代码路径
alps/bootable/recovery/screen_ui.cpp

// Draw the progress bar (if any) on the screen.  Does not flip pages.
// Should only be called with updateMutex locked.
void ScreenRecoveryUI::draw_progress_locked()
{
    if (currentIcon == ERROR) return;


    if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) {
        gr_surface icon = installation[installingFrame];
        gr_blit(icon, 0, 0, gr_get_width(icon), gr_get_height(icon), iconX, iconY);
    }


    if (progressBarType != EMPTY) {
        int iconHeight = gr_get_height(backgroundIcon[INSTALLING_UPDATE]);
        int width = gr_get_width(progressBarEmpty);
        int height = gr_get_height(progressBarEmpty);


        int dx = (gr_fb_width() - width)/2;
#if 0 //wschen 2012-07-11
        int dy = (3*gr_fb_height() + iconHeight - 2*height)/4;
#else
        int dy = (gr_fb_height() - 8 * height)/4;
#endif


        // Erase behind the progress bar (in case this was a progress-only update)
        gr_color(0, 0, 0, 255);
        gr_fill(dx, dy, width, height);


        if (progressBarType == DETERMINATE) {
            float p = progressScopeStart + progress * progressScopeSize;
            int pos = (int) (p * width);


            if (rtl_locale) {
                // Fill the progress bar from right to left.
                if (pos > 0) {
                    gr_blit(progressBarFill, width-pos, 0, pos, height, dx+width-pos, dy);
                }
                if (pos < width-1) {
                    gr_blit(progressBarEmpty, 0, 0, width-pos, height, dx, dy);
                }
            } else {
                // Fill the progress bar from left to right.
                if (pos > 0) {
                    gr_blit(progressBarFill, 0, 0, pos, height, dx, dy);
                }
                if (pos < width-1) {
                    gr_blit(progressBarEmpty, pos, 0, width-pos, height, dx+pos, dy);
                }
            }
        }
    }
}

解析:
        int dx = (gr_fb_width() - width)/2; //进度条横坐标
        int dy = (gr_fb_height() - 8 * height)/4; //进度条纵坐标

通过调节dy的除数(这里是4)来改变进度条上下位置,除数越大越靠上移动,
如:
        int dy = (gr_fb_height() - 8 * height)/6; //进度条往屏幕上方移动


阅读(922) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~