I want to show a PopUpWindow under a LinearLayout
after closing soft keyboard when clicking a button.
This is what I looking for
When user click the button,the keyboard hide,then the PopUpWindow show under the LinearLayout
(area of the keyboard initially). Like this picture below
I try this code:
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//hide the keyboard
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
LinearLayout bottomBar = (LinearLayout)findViewById(R.id.bottomBar);
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = inflater.inflate(R.layout.popup_window, null);
// create the popup window
int width = LinearLayout.LayoutParams.MATCH_PARENT;
int height = LinearLayout.LayoutParams.WRAP_CONTENT;
boolean focusable = true; dismiss it
final PopupWindow popupWindow = new PopupWindow(popupView, width, height, focusable);
// show the popup window
popupWindow.showAtLocation(bottomBar, Gravity.BOTTOM, 0, 0);
}
}
But end up the PopUpWindow
show like this:
The LinearLayout
which contain the button,going to the bottom of screen when the keyboard is hide,the PopUpWindow
show on top of the LinearLayout
,so it become invisible.Like the image below:
So how can I get the desire behavior like the 1st picture?PopUpWindow show under the LinearLayout
after the keyboard is hide.