fungetScreenHeight(ctx:Context?):Int{ val dm = DisplayMetrics() val wm = ctx?.getSystemService(Context.WINDOW_SERVICE) as WindowManager wm.defaultDisplay.getMetrics(dm) //忽略底部虚拟导航按键的高度 return dm.heightPixels }
1 2 3 4 5 6
fungetScreenHeight(ctx:Context?):Int{ val point = Point() val wm = ctx?.getSystemService(Context.WINDOW_SERVICE) as WindowManager wm.defaultDisplay.getSize(point) //忽略底部虚拟导航按键的高度 return point.y }
fungetScreenHeight(ctx:Context?):Int{ val dm = DisplayMetrics() val wm = ctx?.getSystemService(Context.WINDOW_SERVICE) as WindowManager wm.defaultDisplay.getMetrics(dm) return dm.widthPixels }
fungetScreenHeight(ctx:Context?):Float{ val dm = DisplayMetrics() val wm = ctx?.getSystemService(Context.WINDOW_SERVICE) as WindowManager wm.defaultDisplay.getMetrics(dm) return dm.density }