Android IME: showing a custom pop-up dialog (like Swype keyboard) which can enter text into the TextView

后端 未结 4 2177
刺人心
刺人心 2021-01-03 04:21

I\'m wondering how I can create a custom pop-up like the one in the screenshot below (borrowed from the Swype keyboard), where I can have a couple of buttons, which each com

4条回答
  •  日久生厌
    2021-01-03 04:54

    Correct answer:

    1. Create a PopupWindow and put your view inside it
    2. Call popupWindow.setClippingEnabled(false)
    3. Call [popupWindow.showAtLocation()](http://developer.android.com/reference/android/widget/PopupWindow.html#showAtLocation(android.view.View, int, int, int)) with a negative Y coordinate.

    This will show your popup above the IME as in your screenshot.

提交回复
热议问题