慕姐4208626
目前找到的方法只能调用内建的动画效果params = new WindowManager.LayoutParams();params.windowAnimations = android.R.style.Animation_Translucent;若改成R.style.custon_anim的话则是怎麼样都没有动画可用的方法是直接搭Handler、Runnable来updateViewLayout但是在改物件大小时会看起来不顺畅仅管已经把呼叫时间改为1ms,一样没辨法每毫秒呼叫一次更新现在是先用Runnable的方法,只做了淡出效果、物件直接放大到固定值代码大致上如下private void createFloatView(){Log.d("HuybnTag","S.createFloatView");btn_exif = new Button(getApplicationContext());btn_exif.setBackgroundResource(R.drawable.exif);wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);exif = new WindowManager.LayoutParams();exif.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;exif.format = PixelFormat.RGBA_8888;exif.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;exif.height = 124;exif.width = 124;exif.gravity = Gravity.CENTER;exif.windowAnimations = android.R.style.Animation_Translucent;.......要离开时运行这个fadeOut(btn_exif,exif);//下面这段改自网络上的代码public void fadeOut(final View notificationView, final LayoutParams params){animTime=300;exif.width=310;exif.height=310;final long startTime = System.currentTimeMillis();Handler handler = new Handler();handler.postDelayed(new Runnable(){public void run(){fadeOutHandler(notificationView, params, startTime);}}, 25);}public void fadeOutHandler(final View notificationView, final LayoutParams params, final long startTime){long timeNow = System.currentTimeMillis();float alpha = (1- ((float)(timeNow - startTime)/animTime) ) * 1.0f;if(alpha<=0) alpha = 0;params.alpha = alpha;Log.d("HuybnTag","alpha= "+alpha);wm.updateViewLayout(notificationView, params);if (timeNow-startTime<animTime){Handler handler = new Handler();handler.postDelayed(new Runnable(){public void run(){fadeOutHandler(notificationView, params, startTime);}}, 25);}