2017-09-22 59 views
0

我在所有的活動中創建了TapTargetView(或TapTargetSequence),它顯示的很好,但對於彈出式菜單的內部視圖,它隱藏在彈出式菜單窗口後面!恰好在活動和彈出菜單之間。我怎麼能把它帶到最前面呢? TapTargetSequence((Activity)上下文)的參數是否正確? 「上下文」或「this」發生錯誤!TapTargetView放在彈出式菜單後面

public class Popup_Menu implements OnClickListener { 

PopupWindow popup;  View layout;  Context context; 
WindowManager wm; 

    void showPopup(final Activity context) { 
     this.context=context; 
         // Inflate the popup_layout.xml 
    LinearLayout viewGroup = (LinearLayout) ((Activity) context).findViewById(R.id.popup); 
    LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    layout = layoutInflater.inflate(R.layout.popup_layout_menu, viewGroup); 

         // Creating the PopupWindow 
     popup = new PopupWindow(context); 
     popup.setContentView(layout); 
         // Clear the default translucent background 
     popup.setBackgroundDrawable(new BitmapDrawable()); 
     popup.showAtLocation(layout, Gravity.BOTTOM, 30 ,0); 

    tapTarget_menu(); 

    }  /////////////////// close of showPopup() ! 








    // TapTaget_menu 
public void tapTarget_menu() { 
    new TapTargetSequence((Activity) context) 
      .targets(
        TapTarget.forView(layout.findViewById(R.id.chkb_menu_remem), "remember", "last lesson") 
// first target 
          .targetCircleColor(R.color.sabz_seyedi) 
          .outerCircleColor(R.color.sabzabi_kmrng) 
          .dimColor(R.color.sabz_seyedi) 
          .titleTextSize(22) 
          .descriptionTextSize(16) 
          .textColor(R.color.white) 
          .drawShadow(true) 
          .transparentTarget(true) 
          .cancelable(false) 
          .targetRadius(60), 
// second target 
        TapTarget.forView(layout.findViewById(R.id.ll_call_menu), "call", "connecting friends!") 
          .targetCircleColor(R.color.sabz_seyedi) 
          .outerCircleColor(R.color.sabzabi_tireh) 
          .dimColor(R.color.sabz_seyedi) 
          .titleTextSize(22) 
          .descriptionTextSize(16) 
          .textColor(R.color.white) 
          .drawShadow(true) 
          .transparentTarget(true) 
          .cancelable(false) 
          .targetRadius(60) 
      ).start(); 
} 

} 

回答

0

我找到了我的解決方案! popup.showAtLocation()後,我改變了這段代碼,就像下面這樣,它可以在PopupWindow之上顯示tapTargetView。 VIVA ME !!!

WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); 
    layoutParams.packageName = context.getPackageName(); 
    layoutParams.format = PixelFormat.TRANSLUCENT; 
    layoutParams.flags = WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; 

然後,出showPopup()方法:

public void tapTarget_menu1(){ 
    TapTarget target = TapTarget.forView(layout.findViewById(R.id.ll_call_menu), "remember", "last lesson"); 
           .targetCircleColor(R.color.sabz_seyedi) 
           .outerCircleColor(R.color.sabzabi_tireh) 
           .titleTextSize(24) 
           .descriptionTextSize(18) 
           .textColor(R.color.black) 
           .drawShadow(true) 
           .cancelable(false) 
           .transparentTarget(true) 
           .targetRadius(60); 

    content = (ViewGroup) layout.findViewById(android.R.id.content); 
    final TapTargetView tapTarget_menu1 = new TapTargetView(context, wm, content, target, new TapTargetView.Listener(){ 
     @Override 
     public void onTargetClick(TapTargetView view) { 
      tapTarget_menu2(); 
      super.onTargetClick(view); 
     } 
    }); 
    ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).addView(tapTarget_menu1, layoutParams); 
}