View popview = View.inflate(activity, R.layout.popwindow_layout, null);
        int width = Dp2pxUtils.Dp2Px(context, 150f);
        popupWindow = new PopupWindow(popview, width, LinearLayout.LayoutParams.WRAP_CONTENT);
        AnimationUtils.showTitlePopWindowAnimation(popview);//给popwindow添加动画
        initPopWindowListview(popview);
        popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        View parent = View.inflate(context, R.layout.activity_main_drawerlayout, null);
        Rect frame = new Rect();
        activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
        int x = Dp2pxUtils.Dp2Px(context, 20f);
        int titleHeight = Dp2pxUtils.Dp2Px(context, 60f);
        /**
         * parent:弹窗放置的父布局
         * Gravity.TOP + Gravity.RIGHT  该布局的右上角
         * x   相对于右上角x方向偏移多少
         * fram.top+titleHeight  y方向上的偏移值。
         */
        popupWindow.showAtLocation(parent, Gravity.TOP + Gravity.RIGHT, x, frame.top + titleHeight);
        popupWindow.setOutsideTouchable(true);
        popupWindow.setFocusable(true);
        popupWindow.update();
        popOutShadow(popupWindow);//使popwindow以外区域阴影显示

popupwindow显示的位置  布局的右上角,标题栏下

相关文章:

  • 2022-12-23
  • 2021-11-13
  • 2021-09-08
  • 2021-10-19
  • 2021-04-05
  • 2022-12-23
  • 2021-11-28
猜你喜欢
  • 2021-05-18
  • 2022-12-23
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案