public void night() {
        if (mNightView == null) {
            mNightView = new TextView(this);
            mNightView.setBackgroundColor(Color.BLACK);
            windowLayout.addView(mNightView);
        }
        try {
            Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(
                    this, com.aurora.R.anim.aurora_menu_cover_enter);
            mNightView.startAnimation(hyperspaceJumpAnimation);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void day() {
        try {
            Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(
                    this, com.aurora.R.anim.aurora_menu_cover_exit);
            mNightView.startAnimation(hyperspaceJumpAnimation);
        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }


private View mNightView = null;

private WindowManager mWindowManager;

@Override

protected void onCreate(Bundle savedInstanceState) {

mWindowManager = (WindowManager)getSystemService(Context.WINDOW_SERVICE);

super.onCreate(savedInstanceState);

}


public void night() {

WindowManager.LayoutParams lp = new WindowManager.LayoutParams(

LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT,

WindowManager.LayoutParams.TYPE_APPLICATION,

WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE

| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,

PixelFormat.TRANSLUCENT);


lp.gravity = Gravity.BOTTOM;// 可以自定义显示的位置

lp.y = 10;

if (mNightView == null) {

mNightView = new TextView(this);

mNightView.setBackgroundColor(0x80000000);

}

try{

mWindowManager.addView(mNightView, lp);

}catch(Exception ex){}


}

public void day(){

try{

mWindowManager.removeView(mNightView);

}catch(Exception ex){}

}

@Override

protected void onResume() {

if(CommonClass.IsNight){

night();

}else{

day();

}

super.onResume();


}

@Override

protected void onDestroy() {

super.onDestroy();

day();

}



<?xml version="1.0" encoding="utf-8"?>
        android:fillAfter="true" >
            android:duration="300"
        android:fromAlpha="0.0"
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
        android:toAlpha="0.4" />


<?xml version="1.0" encoding="utf-8"?>
        android:fillAfter="true" >
            android:duration="300"
        android:fromAlpha="0.4"
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
        android:toAlpha="0.0" />


更多相关文章

  1. android 网络图片查看器
  2. android 如何从sqlite读取数据到spinner下拉中显示
  3. android 计时器,倒计时
  4. 【Android】Toast显示乱码解决办法
  5. Android(安卓)通过经纬度获取地理位置信息
  6. android 实现可拖动的Button
  7. android ListView的分段显示、分页显示(附源码)
  8. android P虚拟按键点击位置加大的问题
  9. Android(安卓)BaseAdapter如何获得每一项并添加按钮事件

随机推荐

  1. RecyclerView详解(二):ItemDecoration使用(k
  2. Fragment 在Android(安卓)SDK1.6上实现
  3. android.support.v4.app.Fragment和andro
  4. Android之使用HttpURLConnection进行网络
  5. android 应用程序全屏(没有状态栏和标题栏
  6. android 手机拍照流程
  7. android 播放来电铃声
  8. 在Android(安卓)Service中弹出系统全屏对
  9. Android中使用log4j
  10. 一个简单android的全选,单选demo