public class Solve7PopupWindow extends PopupWindow {
public Solve7PopupWindow(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.showAsDropDown不起作用
最新推荐文章于 2020-12-01 14:46:04 发布
本文介绍了一个名为Solve7PopupWindow的自定义PopupWindow类。该类扩展了PopupWindow,并重写了showAsDropDown方法以实现特定的高度自适应显示效果。在Android API 24及更高版本中,该类通过获取屏幕可见区域来动态设置PopupWindow的高度。
1万+

被折叠的 条评论
为什么被折叠?



