【发布时间】:2020-05-01 23:50:15
【问题描述】:
只要焦点在edittext上。 键盘打开,所有视图都调整并向上,如下图示例。
Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FileUtils.hideKeyboard(MainActivity.this);
LayoutInflater layoutInflater = (LayoutInflater) MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View customView = layoutInflater.inflate(R.layout.layout,null);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int height = displayMetrics.heightPixels;
int width = displayMetrics.widthPixels;
popupWindow = new PopupWindow(customView, width, 300);
//display the popup window
popupWindow.showAtLocation(rootlayout, Gravity.BOTTOM, 0, 0);
}
});
此代码运行良好,但弹出窗口显示屏幕底部并停留在 rootlayout 上。 我希望这个弹出窗口是打开的,并保持像带有动画的键盘一样。
【问题讨论】:
标签: java android android-keypad android-popupwindow