赞
踩
static public View launcherView; public static void showLauncher(){ instance.runOnUiThread(new Runnable() { @Override public void run() { if(launcherView == null) { launcherView = LayoutInflater.from(instance).inflate(R.layout.launcher, null); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; instance.addContentView(launcherView, params); } } }); } public static void hideLauncher(){ instance.runOnUiThread(new Runnable() { //这里加一个渐隐的动画 @Override public void run() { if(launcherView != null) { AlphaAnimation mHideAnimation = new AlphaAnimation(1.0f, 0.0f); mHideAnimation.setDuration(200); mHideAnimation.setFillAfter(true); launcherView.startAnimation(mHideAnimation); } } }); new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(250); instance.runOnUiThread(new Runnable() { @Override public void run() { if (launcherView != null) { ViewGroup vg = (ViewGroup) launcherView.getParent(); vg.removeView(launcherView); launcherView = null; } } }); } catch (InterruptedException e) { instance.runOnUiThread(new Runnable() { @Override public void run() { if(launcherView != null) { ViewGroup vg = (ViewGroup) launcherView.getParent(); vg.removeView(launcherView); launcherView = null; } } }); } } }).start(); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。