华为手机使umeng分享popwindow被底部导航栏挡住问题
来源:互联网 发布:收淘宝卖家号 编辑:程序博客网 时间:2024/05/16 12:03
本人在工作中遇到umeng分享被底部导航栏挡住的问题,不知道怎么解决,后来经过多番纠结在巧合的情况下发下来了这个方法,验证了一些手机发现可以,所以在此和大家分享一下。
其实这个问题也很简单就是在被挡住的手机上面做一个popwindow的偏移,但问题是如何判断在那些手机上需要偏移,总不能在所有手机上都偏移吧
解决方法:
比较decorview与screenview的高度 如果decorview大于screenview
则 popupWindow.showAtLocation(linearLayout, Gravity.BOTTOM, 0, -getNavigationBarHeight());
否则popupWindow.showAtLocation(linearLayout, Gravity.BOTTOM, 0, 0);
这样就解决了,哈哈哈
然而你真的以为这样就行了吗?并没有 过几天测试妹子就来找我了 说我程序有bug popwindow还是会被底部导航栏挡住,我就说不可能啊,我明明就测试过了,而且显示正常。所以我就去看看她到底是怎么测试的,结果发现,你妹 华为手机的底部导航栏是可以设置隐藏的。所以我写的程序果然有问题。如果隐藏导航栏,在弹出popwindow时再将导航栏显示出来会挡住popwindow,而如果一开始将导航栏显示,弹出popwindow后再将导航栏隐藏,底部就会空出一部分,非常难看。所以还是要接着改。
解决方法:
每次导航栏消失或者显示都会使view重新绘制 所以我在popwindow的contentview(我的是linearlayout)上做了些改动,在这个contentview的Onlayout方法里面判断是否需要偏移,如果偏移就设置这个contentview.setPadding(0,0,0,getNavigationBarHeight());不偏移就正常显示contentview.setPadding(0,0,0,0);
代码:
/** * Created by wyq on 2015/12/16. */public class MyLinearLayout extends LinearLayout { private static final String TAG ="CustomShareBoard"; private Context context; public MyLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); this.context= context; } public MyLinearLayout(Context context) { super(context); this.context= context; } public MyLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); this.context= context; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { if(!isOffset()) { L.i(TAG,"不需要偏移"); if (this.getPaddingBottom()!=0) { this.setPadding(0, 0, 0, 0); } } else{ L.i(TAG, "需要偏移"); this.setPadding(0, 0, 0, getNavigationBarHeight()); invalidate(); } super.onLayout(true, l, t, r, b); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); } private int getNavigationBarHeight() { Resources resources = this.context.getResources(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); return resources.getDimensionPixelSize(resourceId); } public boolean isOffset() { return getDecorViewHeight() > getScreenHeight(); } public int getDecorViewHeight(){ return ((Activity)this.context).getWindow().getDecorView().getHeight(); } public int getScreenHeight(){ DisplayMetrics dm = new DisplayMetrics(); ((Activity)this.context).getWindowManager().getDefaultDisplay().getMetrics(dm);//当前activity return dm.heightPixels; }}
- 华为手机使umeng分享popwindow被底部导航栏挡住问题
- PopupWindow 在华为手机等某些自带虚拟导航栏底部被挡住的解决
- Android开发问题:底部弹出popwindow,会被某些手机底部的菜单栏挡住
- 华为底部虚拟导航栏挡住布局
- popwindow 挡住 魅族手机虚拟按键
- navigation bar底部导航栏挡住屏幕其他控件处理
- APP 审核被拒 umeng 分享问题
- 华为等手机获得底部虚拟导航的高度
- 【Popwindow】自定义popwindow的底部间隙问题
- UMeng分享proguard出现问题
- 【AmazeUI】底部导航栏与分享按钮
- 设置popwindow不被键盘挡住
- Android 华为手机 导航栏隐藏
- 华为Mate9导航栏遮挡PopupWindow底部布局
- Popwindow中弹出软键盘后挡住Pop问题
- PopupWindow 与 华为手机登底部虚拟导航重叠的问题解决方案
- UMeng分享
- 底部虚拟按键导航栏问题
- Brocade交换机配置DAI(Dynamic ARP Inspection)和DHCP Snooping
- python核心编程-实例的默认参数
- JAVA并发编程笔记五
- 关于swift的访问级别
- Android架构简洁之道
- 华为手机使umeng分享popwindow被底部导航栏挡住问题
- Aexi(8)-Caret位置标记的再思考
- 《UML之用例图》
- LeetCode 203:Remove Linked List Elements
- [洛谷1003]铺地毯
- [洛谷1017]进制转换
- 我看Java虚拟机(8)---高效并发
- [洛谷1067]多项式输出
- [洛谷1540]机器翻译