网友通过本文主要向大家介绍了android 系统动画,android开机动画修改,android加载动画效果,android动画,android 属性动画等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
修改Android系统关机动画,android关机动画
文件路径:frameworks\base\services\core\java\com\android\server\power\ShutdownThread.java
在beginShutdownSequence()方法中:
1 private static void beginShutdownSequence(Context context) { 2 ...... 3 // throw up an indeterminate system dialog to indicate radio is 4 // shutting down. 5 //*********************** 系统默认的Dialog *********************** 6 /*ProgressDialog pd = new ProgressDialog(context); 7 pd.setTitle(context.getText(com.android.internal.R.string.power_off)); 8 pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress)); 9 pd.setIndeterminate(true); 10 pd.setCancelable(false); 11 pd.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); 12 pd.show();*/ 13 //*********************** 替换为自定义的全屏Dialog *********************** 14 Point outSize = new Point(); 15 Dialog dialog = new Dialog(context, android.R.style.Theme_Black_NoTitleBar_Fullscreen); 16 IndeterminateProgressBar view = new IndeterminateProgressBar(context); 17 dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); 18 dialog.getWindow().getWindowManager().getDefaultDisplay().getSize(outSize); //获取屏幕宽高 19 dialog.setContentView(view, new LayoutParams(outSize.x, outSize.y)); //设置自定义view宽高为全屏 20 dialog.show(); 21 22 ...... 23 }注意:必须要设置 dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); 之前忘了加导致什么都不显示 替换的自定义View:
1 class IndeterminateProgressBar extends View { 2 static final String TAG = "ProgressBar"; 3 private int delayMillis = 30; 4 private Handler mHandler; 5 private ArrayList<Entity> entities; 6 private int width = 0; 7 // private int height = 0; 8 private int r = 15; 9 private int shift = 20; 10 private int radius = 3; 11 private int color = Color.WHITE; 12 private long time = 0; 13 private boolean started = false; 14 public IndeterminateProgressBar(Context context) { 15 super(context); 16 init(); 17 } 18 @Override 19 protected void onLayout(boolean changed, int left, int top, int right, 20 int bottom) { 21 super.onLayout(changed, left, top, right, bottom); 22 width = getLayoutParams().width / 2; 23 // height = getLayoutParams().height; 24 if (width > 0) { 25 radius = width / 20; 26 r = 2 * width / 5; 27 //shift = width / 2; 28 shift = width / 1; 29 } 30 } 31 private void init() { 32 setBackgroundResource(android.R.color.transparent); 33 mHandler = new Handler(new Handler.Callback() { 34 @Override 35 public boolean handleMessage(Message msg) { 36 for (Entity e : entities) { 37 e.update(); 38 } 39 invalidate(); 40 mHandler.sendEmptyMessageDelayed(0, delayMillis); 41 time += delayMillis; 42 return false; 43 } 44 }); 45 } 46 public void setColor(int color) { 47 this.color = color; 48 } 49 public void stop() { 50 mHandler.removeMessages(0); 51 started = false; 52 invalidate(); 53 } 54 public boolean isStart() { 55 return started; 56 } 57 public void start() { 58 if (started) 59 return; 60 started = true; 61 time = 0; 62 entities = new ArrayList<IndeterminateProgressBar.Entity>(); 63 float s = .25f; 64 entities.add(new Entity(0, color, 0)); 65 entities.add(new Entity(1 * s, color, delayMillis * 4)); 66 entities.add(new Entity(2 * s, color, delayMillis * 8)); 67 entities.add(new Entity(3 * s, color, delayMillis * 12)); 68 entities.add(new Entity(4 * s, color, delayMillis