美文网首页
在Android 7.0上PopupWindow.showAsD

在Android 7.0上PopupWindow.showAsD

作者: smallestt | 来源:发表于2018-03-29 18:33 被阅读0次
/**
 * Created by wangtingting on 2018/3/29.
 * 在Android 7.0上PopupWindow.showAsDropDown不起作用的解决方法
 */

public class MyPopWindow extends PopupWindow{
    public MyPopWindow(View mMenuView, int matchParent, int matchParent1) {
        super(mMenuView, matchParent,matchParent1);
    }

    @Override
    public void showAsDropDown(View anchor) {
        if (Build.VERSION.SDK_INT >= 24) {
            Rect rect = new Rect();
            anchor.getGlobalVisibleRect(rect);
            int h = anchor.getResources().getDisplayMetrics().heightPixels - rect.bottom;
            setHeight(h);
        }
        super.showAsDropDown(anchor);
    }
}

相关文章

网友评论

      本文标题:在Android 7.0上PopupWindow.showAsD

      本文链接:https://www.haomeiwen.com/subject/fslvcftx.html