Android系统覆盖4.2.2

时间:2013-09-28 19:09:29

标签: java android eclipse android-softkeyboard

    // fetch window manager object 
     mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
     // set layout parameter of window manager
     WindowManager.LayoutParams mParams = new WindowManager.LayoutParams(
                30, // width of layout 30 px
                200, // height is equal to full screen
                WindowManager.LayoutParams.TYPE_PHONE, // Type Ohone, These are non-application windows providing user interaction with the phone (in particular incoming calls).
                WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
               // WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH // this window won't ever get key input focus  
                PixelFormat.TRANSLUCENT
                );      
     mParams.gravity = Gravity.LEFT | Gravity.TOP;   
     //mParams.setTitle("Load Average");

     LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);

     mWindowManager.addView(touchLayout, mParams);

     touchLayout.setOnTouchListener(this);

这只是代码的一小部分。我的第一个问题是在视图中接收触摸,但是,在此服务运行时触摸其他应用程序中的编辑文本框时,软键盘无法打开。我已经尝试了各种标志来解决问题,但是我没有将触摸事件注册到屏幕上的部分的能力,如上面的代码中所示。

我没有想法,有没有人知道我哪里出错了,或Android 4.2.2 +的替代解决方案?

1 个答案:

答案 0 :(得分:0)

试试这个:

Dialog dialog = new Dialog(this,android.R.style.Theme_DeviceDefault_Dialog_NoActionBar_MinWidth);
    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    dialog.setContentView(new EditText(this));
    dialog.show();