我很难像软键盘一样实现弹出窗口。我的意思是,当你在android中打开弹出窗口时弹出窗口中的视图是禁用的(你不能做什么,直到弹出窗口解除)。但是当软键盘打开时,视图总是在软键盘上方。
注意:不需要像view.setVisibility(View.GONE)
或view.setVisibility(View.VISIBLE)
修改
简单地说,当弹出式显示从下到上看起来像软键盘时,如何进行布局/查看?
答案 0 :(得分:0)
为此你必须创建一个弹出的自定义视图,你必须为你的视图创建一个不同的xml文件并定义它的高度宽度,使高度换行包含内容。你的视图不受其它影响。对话框弹出窗口,在后台禁用任何内容。
示例: - 假设你有一个名为dialog_pop_up的弹出窗口,
public void showPopUpDialog(Context context,ImageView imagebuttonPopUP) {
try {
View v = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.dialog_pop_up, null, false);
int[] location = new int[2];
//This is the button which triggers pop up
imagebuttonPopUP.getLocationOnScreen(location);
//Initialize the Point with x, and y positions
Point p = new Point();
p.x = location[0];
p.y = location[1];
int popupWidth = mActivity.getResources().getDimensionPixelOffset(R.dimen.home_screen_dialog_width);//Utility.dpToPx(mActivity,133);
int OFFSET_Y = imagebuttonPopUP.getHeight();
int OFFSET_X = imagebuttonPopUP.getWidth();
final PopupWindow window = new PopupWindow(v, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, true);
window.setWidth(popupWidth);
window.setOutsideTouchable(true);
window.setTouchable(true);
window.setFocusable(true);
window.setBackgroundDrawable(new BitmapDrawable());
//Initialize your view here.
TextView TextView1 = (TextView) v.findViewById(R.id.textview1);
TextView TextView2 = (TextView) v.findViewById(R.id.textview2);
LinearLayout Layout = (LinearLayout) v.findViewById(R.id.linearlayout2);
View dividerView = v.findViewById(R.id.view_divider);
//Click listeners of your views
TextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//your code here
//to dismiss window
window.dismiss();
}
});
TextView2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//code
}
});
window.showAtLocation(imagebuttonPopUP, Gravity.NO_GRAVITY, p.x + OFFSET_X - popupWidth, p.y + OFFSET_Y);
} catch (Exception ex) {
Logger.e(TAG, ex.getMessage());
}
}
答案 1 :(得分:0)
是的,您可以使用底部的两个翻译动画创建自定义对话框。 检查droid孩子回答他已经按照你的方式完成了。 Answer