PopUtils.java 1.57 KB
Newer Older
1
package com.ydl.ydlcommon.utils;
konghaorui committed
2 3 4 5 6 7 8 9

import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.PopupWindow;
10
import com.ydl.ydlcommon.view.MoreClickView;
konghaorui committed
11 12 13 14 15 16 17


/**
 * Created by Wi1ls on 2016/10/17;
 */
public class PopUtils {
    public static PopupWindow showMoreItem(Context context, View view, int offX, int offY){
18
        MoreClickView v=  new MoreClickView(context);
konghaorui committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
        WindowManager windowManager= (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

        final PopupWindow popupWindow=new PopupWindow(v, windowManager.getDefaultDisplay().getWidth(),
                windowManager.getDefaultDisplay().getHeight());
        v.setPopupWindow(popupWindow);
        popupWindow.setFocusable(false);
        popupWindow.setOutsideTouchable(true);
        popupWindow.setBackgroundDrawable(new BitmapDrawable());
//        popupWindow.showAsDropDown(view);
        popupWindow.showAtLocation(view, Gravity.CENTER,0,0);
        return popupWindow;
    }

    public static PopupWindow showHomePop(Context context,View content,View view){

        final PopupWindow popupWindow=new PopupWindow(content, ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
        popupWindow.setFocusable(false);
        popupWindow.setOutsideTouchable(true);
        popupWindow.setBackgroundDrawable(new BitmapDrawable());
        popupWindow.showAsDropDown(view, 0,0);
        return popupWindow;
    }
}