模拟器中的弹出窗口:
Real设备中的弹出窗口:
正如您所看到的,模拟器中显示的弹出窗口比实际设备更正确。我不知道为什么。 当我修改弹出窗口以获得EditText的焦点时,就发生了这种情况:
container = inflater.inflate(R.layout.play_exercise_popup, null);
fadeContainer = inflater.inflate(com.phongphonix.trackingbodybuilding.R.layout.faded_popup, null);
popupWindow = new PopupWindow(container, CommonLib.convertDpToPx(activity, 350), LinearLayout.LayoutParams.WRAP_CONTENT);
fadePopup = new PopupWindow(fadeContainer, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, false);
fadePopup.showAtLocation(viewHolder.containerTest, Gravity.NO_GRAVITY, 0, 0);
popupWindow.showAtLocation(viewHolder.containerTest, Gravity.CENTER, 0, 0);
popupWindow.setFocusable(true);
popupWindow.setTouchInterceptor(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
popupWindow.dismiss();
return true;
}
return false;
}
});
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
fadePopup.dismiss();
}
});
popupWindow.update();
它有什么问题?
答案 0 :(得分:0)
我找到了解决方案:使用Gravity.CENTER_HORIZONTAL而不是Gravity.CENTER