您的位置:首页 > 移动开发 > Android开发

android 7.0 PopupWindow bug修复,测试没啥问题

2017-03-09 18:43 302 查看
View view = LayoutInflater.from(this).inflate(R.layout.xxx, null);
popupWindow = new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true) {
@Override
public void showAsDropDown(View anchor) {
Class<?> popupwindow = PopupWindow.class;
try {
Method m2 = popupwindow.getDeclaredMethod("computeGravity");
m2.setAccessible(true);
int invoke = (int) m2.invoke(popupWindow);
int gravity = Gravity.START | Gravity.TOP;
if (invoke == gravity) {
Rect rect = new Rect();
anchor.getGlobalVisibleRect(rect);
int h = anchor.getResources().getDisplayMetrics().heightPixels - rect.bottom;
setHeight(h);
}
} catch (Exception e) {
e.printStackTrace();
}
super.showAsDropDown(anchor);
}
};
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.showAsDropDown(dropView);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: