2017-04-27 1 views
0

je veux déplacer et rejeter ma fenêtre popup comme commentaire facebook/comme fenêtre popup faire. Je me suis essayé et j'ai cherché mais j'ai échoué. Pouvez-vous s'il vous plaît m'aider à le faire.fenêtre popup ne bouge pas comme commentaire facebook/comme fenêtre popup faire

mon code:

int display_width=context.getResources().getDisplayMetrics().widthPixels; 
       int display_height=context.getResources().getDisplayMetrics().heightPixels; 

       final PopupWindow popupWindow=new PopupWindow(viewTmp_comment, display_width, display_height-60,true); 
       popupWindow.setOutsideTouchable(false); 

       popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); 
       popupWindow.showAsDropDown(view); 
       popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); 
       popupWindow.setTouchable(true); 
       popupWindow.showAtLocation(view, Gravity.CENTER,0,0); 
       popupWindow.setContentView(view); 

       popupWindow.getContentView().setOnDragListener(new View.OnDragListener() { 
        @Override 
        public boolean onDrag(View view, DragEvent dragEvent) { 

         switch (dragEvent.getAction()) { 
          case MotionEvent.ACTION_DOWN: 
           Toast.makeText(context,"Down",Toast.LENGTH_LONG).show(); 
           popupWindow.dismiss(); 
           break; 

//      case MotionEvent.ACTION_MOVE: 
//      Toast.makeText(context,"Up",Toast.LENGTH_LONG).show(); 
////      popupWindow.dismiss(); 
//      break; 
         } 

         return false; 
        } 
       }); 

Répondre

0

Le dialogue facebook monte donc vous devez traduire de la position actuelle vers le haut

<translate 
    android:fromYDelta="0%p" 
    android:toYDelta="-30%p" 
    android:duration="1000" /> 

il est au sujet de l'animation, vous devriez jeter un oeil: Android animation

mettre à jour: définir votre style: p.ex.

<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog"> <item name="android:windowAnimationStyle">@style/MyAnimation.Windo‌​w</item> </style> <style name="MyAnimation.Window" parent="@android:style/Animation.Activity"> <item name="android:windowExitAnimation">@anim/slide_up</item> </style> 

et mis popupWindow.setAnimationStyle (R.style.DialogTheme) ne R.anim

fenêtre
+0

ne bouge pas un peu – AAA

+0

avez-vous ajouté l'animation à votre vue dialogue? –

+0

oui j'ai ajouté de l'animation mais pas travaillé – AAA