2016-12-29 91 views
0

彈出顯示在仿真器:彈出窗口重力測量在仿真器不同,真實設備

Popup Show in Emulator

彈出展現在真實設備:

Popup show in real device

正如你可以看到,在彈出窗口中顯示在模擬器中比在實際設備中更正確。我不知道爲什麼。 當我修改彈出獲得焦點的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

我發現解決方案:使用Gravity.CENTER_HORIZONTAL而不是Gravity.CENTER