Android 修改系统关机动画的实现

Android 修改系统关机动画的实现,第1张

概述    在Android系统移植做自己的移动设备,肯定会遇到更改开机或者关机画面,配置自己产品logo这点是必须的,这些都要在源码中修改,然后编译,下面给大家介绍个关机动画修改,一个简单示例!

     在AndroID 系统移植做自己的移动设备,肯定会遇到更改开机或者关机画面,配置自己产品logo 这点是必须的,这些都要在源码中修改,然后编译,下面给大家介绍个关机动画修改,一个简单示例!

文件路径:frameworks\base\services\core\java\com\androID\server\power\ShutdownThread.java

在beginShutdownSequence()方法中:

private static voID beginShutdownSequence(Context context) {  ...... 3   // throw up an indeterminate system dialog to indicate radio is  // shutting down.  //*********************** 系统默认的Dialog  ***********************  /*ProgressDialog pd = new ProgressDialog(context);  pd.setTitle(context.getText(com.androID.internal.R.string.power_off));  pd.setMessage(context.getText(com.androID.internal.R.string.shutdown_progress));  pd.setIndeterminate(true);  pd.setCancelable(false);  pd.getwindow().setType(WindowManager.LayoutParams.TYPE_KEyguard_DIALOG);  pd.show();*/  //*********************** 替换为自定义的全屏Dialog  ***********************  Point outSize = new Point();  Dialog dialog = new Dialog(context,androID.R.style.theme_Black_NoTitlebar_Fullscreen);  IndeterminateProgressbar vIEw = new IndeterminateProgressbar(context);  dialog.getwindow().setType(WindowManager.LayoutParams.TYPE_KEyguard_DIALOG);  dialog.getwindow().getwindowManager().getDefaultdisplay().getSize(outSize); //获取屏幕宽高  dialog.setContentVIEw(vIEw,new LayoutParams(outSize.x,outSize.y));     //设置自定义view宽高为全屏  dialog.show();    ......}

注意:必须要设置 dialog.getwindow().setType(WindowManager.LayoutParams.TYPE_KEyguard_DIALOG); 之前忘了加导致什么都不显示 

替换的自定义view:

class IndeterminateProgressbar extends VIEw {  static final String TAG = "Progressbar";  private int delayMillis = 30;  private Handler mHandler;  private ArrayList<Entity> entitIEs;  private int wIDth = 0;  // private int height = 0;  private int r = 15;  private int shift = 20;  private int radius = 3;  private int color = color.WHITE;  private long time = 0;  private boolean started = false;  public IndeterminateProgressbar(Context context) {    super(context);    init();  }  @OverrIDe  protected voID onLayout(boolean changed,int left,int top,int right,int bottom) {    super.onLayout(changed,left,top,right,bottom);    wIDth = getLayoutParams().wIDth / 2;    // height = getLayoutParams().height;    if (wIDth > 0) {      radius = wIDth / 20;      r = 2 * wIDth / 5;      //shift = wIDth / 2;      shift = wIDth / 1;    }  }  private voID init() {    setBackgroundResource(androID.R.color.transparent);    mHandler = new Handler(new Handler.Callback() {      @OverrIDe      public boolean handleMessage(Message msg) {        for (Entity e : entitIEs) {          e.update();        }        invalIDate();        mHandler.sendEmptyMessageDelayed(0,delayMillis);        time += delayMillis;        return false;      }    });  }  public voID setcolor(int color) {    this.color = color;  }  public voID stop() {    mHandler.removeMessages(0);    started = false;    invalIDate();  }  public boolean isstart() {    return started;  }  public voID start() {    if (started)      return;    started = true;    time = 0;    entitIEs = new ArrayList<IndeterminateProgressbar.Entity>();    float s = .25f;    entitIEs.add(new Entity(0,color,0));    entitIEs.add(new Entity(1 * s,delayMillis * 4));    entitIEs.add(new Entity(2 * s,delayMillis * 8));    entitIEs.add(new Entity(3 * s,delayMillis * 12));    entitIEs.add(new Entity(4 * s,delayMillis * 16));    // entitIEs.add(new Entity(5 * s,delayMillis * 20));      if (mHandler != null)        mHandler.sendEmptyMessage(0);    }    @OverrIDe    protected voID onDraw(Canvas canvas) {      if (entitIEs != null && entitIEs.size() > 0) {        for (Entity e : entitIEs) {          e.draw(canvas);        }      }      super.onDraw(canvas);    }    class Entity {      private float x;      private float y;      private int color;      private Paint paint;      private double sp = 0;      private long delay;      private int sec = 0;      private float pec = 0;      boolean visiable = true;      public float getInterpolation(float input) {        return (float) (Math.cos((input + 1) * Math.PI) / 2.0f) + 0.5f;      }      public Entity(float sp,int color,int delay) {        paint = new Paint();        paint.setAntiAlias(true);        paint.setStyle(Paint.Style.FILL);        this.color = color;        this.sp = sp;        this.delay = delay;        paint.setcolor(this.color);      }      public voID update() {        if (time < delay)          return;        visiable = true;        pec += 0.03;        if (pec > 1) {          pec = 0;          sec = ++sec == 3 ? 0 : sec;          delay = sec == 0 ? time + delayMillis * 22 : time + delayMillis              * 3;          visiable = sec == 0 ? false : true;        }        double θ = Math.PI            * .5            + (sec == 0 ? 0 : sec * Math.PI / sec)            - (sec == 0 ? 0 : sp)            + (Math.PI * (sec == 1 ? 2 : 1) - (sec == 0 ? sp : 0) + (sec == 2 ? sp                : 0)) * getInterpolation(pec);        x = (float) (r / 2 * Math.cos(θ)) + shift / 2;        y = (float) (r / 2 * Math.sin(θ)) + shift / 2;      }      public voID draw(Canvas canvas) {        if (!visiable || x == 0 || y == 0)          return;        canvas.save();        canvas.translate(x,y);        canvas.drawCircle(x,y,radius,paint);        canvas.restore();      }    }    @OverrIDe    protected voID onAttachedToWindow() {      super.onAttachedToWindow();      if (getVisibility() == VIEw.VISIBLE) {        start();      }    }    @OverrIDe    protected voID onDetachedFromWindow() {      super.onDetachedFromWindow();      stop();    }    public voID setDelayMillis(int delayMillis) {      this.delayMillis = delayMillis;    }}

效果图:

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

总结

以上是内存溢出为你收集整理的Android 修改系统关机动画的实现全部内容,希望文章能够帮你解决Android 修改系统关机动画的实现所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1147991.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)

保存