美文网首页
Android7.0上showAsDropDown问题

Android7.0上showAsDropDown问题

作者: 周晓风 | 来源:发表于2017-04-08 10:51 被阅读129次

最近在Android7.0手机上发现PopWindow使用showAsDropDown(View view)方法时,View展示会从顶部充满屏幕,而不是展示在view的下方,测试发现在7.0以下和7.1均没有类似问题。Version=24时会出现!

在项目使用中,需要重写PopWindow的showAsDropDown方法:

@Override

public voidshowAsDropDown(View view) {

if(Build.VERSION.SDK_INT==24) {

Rect rect =newRect();

view.getGlobalVisibleRect(rect);

intheight = view.getResources().getDisplayMetrics().heightPixels- rect.bottom;

setHeight(height);

}

super.showAsDropDown(view);

}

相关文章

网友评论

      本文标题:Android7.0上showAsDropDown问题

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