如何在android eclipse中创建一个较小的叠加活动

时间:2013-03-05 23:46:38

标签: java android

我已经成功创建了一个叠加活动,允许将触摸输入发送到它后面的窗口。但是,一切正常,它会大大减慢设备速度,我的猜测是因为它创建了如此大的叠加层?我真的不需要覆盖屏幕的整个区域,技术上可能会像2 x 2像素一样大。

这是我的代码

inflater = LayoutInflater.from(getApplicationContext());
final WindowManager.LayoutParams params = new  WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_FULLSCREEN, PixelFormat.TRANSLUCENT);

    params.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
    params.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
    params.flags |= WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
    //params.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;


    WindowManager wm = (WindowManager) getApplicationContext().getSystemService(WINDOW_SERVICE);
    ViewGroup mTopView = (ViewGroup)inflater.inflate(R.layout.dummy, null);
    getWindow().setAttributes(params);
    mTopView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    wm.addView(mTopView, params);

这正是我想要它做的,但正如我所说,它明显减慢了设备的速度。如何创建叠加层但仍保留系统性能?

0 个答案:

没有答案