首页 > Windows开发 > 详细

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

时间:2016-04-26 14:16:27      阅读:172      评论:0      收藏:0      [点我收藏+]
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显示的位置 布局的右上角,标题栏下

原文:http://www.cnblogs.com/epmouse/p/5434756.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!