Popupwind簡單實現

    private void showDetailsMoreWindow(View asDropDown) {
        if (popupWindow == null) {
            View view = LayoutInflater.from(this).inflate(
                    R.layout.poupwind_details_more, null);
            tvDetailesMoreHome = (TextView) view.findViewById(R.id.tv_detailes_more_home);
            tvDetailesMoreCollect = (TextView) view.findViewById(R.id.tv_detailes_more_collect);
            tvDetailesMoreShare = (TextView) view.findViewById(R.id.tv_detailes_more_share);
            tvDetailesMoreHome.setOnClickListener(this);
            tvDetailesMoreCollect.setOnClickListener(this);
            tvDetailesMoreShare.setOnClickListener(this);
            popupWindow = new PopupWindow(view, WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.WRAP_CONTENT, false);
            popupWindow = new PopupWindow(view);
        }
        // 使其聚集
        popupWindow.setFocusable(true);
        // 設置允許在外點擊消失
        popupWindow.setOutsideTouchable(true);
        // 這個是爲了點擊返回Back”也能使其消失,並且並不會影響背景
        popupWindow.setBackgroundDrawable(new BitmapDrawable());
        // 設置SelectPicPopupWindow彈出窗體的寬
        int width = this.getWindowManager().getDefaultDisplay().getWidth();
        popupWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
        // 設置SelectPicPopupWindow彈出窗體的高
        popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        // 設置SelectPicPopupWindow彈出窗體動畫效果
//        popupWindow.setAnimationStyle(R.style.PopupAnimation);
        popupWindow.showAsDropDown(asDropDown);
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章