2

I'm linking a PopupWindow to a TextView placed inside a ScrollView but when the view automatically scrolls to show the virtual keyboard the PopupWindow completely overlap the text box. If I manually scroll the view with the keyboard shown the PopupWindow moves automatically to the right place.

My actual code is the following:

    popupBinding = PasswordPopupBinding.inflate(LayoutInflater.from(getContext()));
    View suggestionView = popupBinding.getRoot();
    PopupWindow suggestionPopup = new PopupWindow();
    suggestionPopup.setContentView(suggestionView);
    binding.passwordTextView.setSuggestionPopup(suggestionPopup);

Is there a way to avoid the overlap?

TheOni
  • 810
  • 9
  • 26
  • can you try setFocusable(true), i'm pulling my reference from [android documentation for PopupWindow](https://developer.android.com/reference/android/widget/PopupWindow), also if you peek at the constructors, there's one that takes in a View as a parameter. – EvOlaNdLuPiZ Jul 11 '18 at 16:34
  • @EvOlaNdLuPiZ setFocusable don't change the behaviour, I tried also setOverlapAnchor(false) but no way – TheOni Jul 11 '18 at 19:46
  • since you asked _is there a way to avoid the overlap_, to isolate this issue is adding the onScrollChange listener to your scroll layout. then, when it scrolls it checks if the PopupWindow is active (not null) && if PopupWindow .isShowing(), if you're scrolling dismiss the PopupWindow or something similar. – EvOlaNdLuPiZ Jul 11 '18 at 20:06
  • another possible improvement would be to control the layout from invoking the soft keyboard past a certain distance (you can prevent the keyboard from moving at all). [peek at this](https://stackoverflow.com/questions/5516216/how-to-avoid-soft-keyboard-pushing-up-my-layout) – EvOlaNdLuPiZ Jul 11 '18 at 20:13

0 Answers0