문제

So I am making a sticky note sorta thing that always appears on top and user can press on it to type on it. So here is my working code:

 mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE); 
 LayoutInflater layoutInflater = 
 (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 myView = layoutInflater.inflate(R.layout.notepad, null ); //notepad.xml contains the EditText

  WindowManager.LayoutParams params = new WindowManager.LayoutParams(
        WindowManager.LayoutParams.WRAP_CONTENT,
        WindowManager.LayoutParams.WRAP_CONTENT,
        WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
        WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
        PixelFormat.TRANSLUCENT);
  mWindowManager.addView(myView, params);

The problem is that when I use the flag TYPE_SYSTEM_OVERLAY, I can't get focus to type on the EditText. Alternate would be to use TYPE_SYSTEM_ALERT and I can use the EditText to type on, but then the entire background would freeze. How can I allow the user to type without interrupting background activity (aka game, video, scrolling thru Facebook etc)

도움이 되었습니까?

해결책

There is an opensource library for that. Its called the standOut library. Have a look.

enter image description here

It may help you.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top