Android WindowManager does not move after keyboard visibility

Window displayed on screen

public class FlatingViewService extends Service{
      public static WindowManager windowManager;
              ...

    windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
     ...

    //Floating View Layout
   li = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);

   myView = li.inflate(R.layout.product_response_card, null);

  name =  (TextView) myView.findViewById(R.id.name);

  editTextName = (TextView) myView.findViewById(R.id.editTextName);
    ...

    //Layout Parameters
    ...
   response_card_params.softInputMode =  WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE;

When a user tries to enter some text in editText, a keyboard appears, but on top of the edit text. Thus, the user does not see anything.

What is the problem?

+4
source share
2 answers

The problem is solved.

//Layout Parameters for Product response card
        layout_params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_PHONE,
                WindowManager.LayoutParams.FLAG_DIM_BEHIND,
                PixelFormat.TRANSLUCENT);
        layout_params.gravity = Gravity.LEFT;
        layout_params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN;

I used WindowManager.LayoutParams.TYPE_SYSTEM_ALERTinsteadWindowManager.LayoutParams.TYPE_PHONE

And WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN

+6
source

API 19 SOFT_INPUT_ADJUST_PAN SOFT_INPUT_ADJUST_RESIZE TYPE_SYSTEM_ALERT TYPE_TOAST ( TYPE_VOLUME_OVERLAY API 21 22, API 23 TYPE_VOLUME_OVERLAY ).

TYPE_SYSTEM_ALERT TYPE_PHONE.

+2

Source: https://habr.com/ru/post/1524517/


All Articles