当前位置:网站首页>获取屏幕宽高工具类
获取屏幕宽高工具类
2022-06-24 07:02:00 【Simon66991】
public class ScreenUtils {
/** * 获取屏幕高度(px) */
public static int getScreenHeight(Context context) {
return context.getResources().getDisplayMetrics().heightPixels;
}
/** * 获取屏幕高度 */
public static DisplayMetrics getDisplayMetricsHeight(final Context pContext) {
return pContext.getResources().getDisplayMetrics();
}
public static int getDisplayWidthPixelsHeight(final Context pContext) {
return cn.jkwspersonal.util.ScreenUtils.getDisplayMetricsHeight(pContext).widthPixels;
}
public static int getDisplayHeightPixelsHeight(final Context pContext) {
return cn.jkwspersonal.util.ScreenUtils.getDisplayMetricsHeight(pContext).heightPixels;
}
public static float getDisplayXDpiHeight(final Context pContext) {
return cn.jkwspersonal.util.ScreenUtils.getDisplayMetricsHeight(pContext).xdpi;
}
public static float getDisplayYDpiHeight(final Context pContext) {
return cn.jkwspersonal.util.ScreenUtils.getDisplayMetricsHeight(pContext).ydpi;
}
public static float getDisplayDensityHeight(final Context pContext) {
return cn.jkwspersonal.util.ScreenUtils.getDisplayMetricsHeight(pContext).density;
}
public static int dipToPxHeight(final Context pContext, final int pDip) {
return (int) (pDip * cn.jkwspersonal.util.ScreenUtils.getDisplayDensityHeight(pContext) + 0.5f);
}
/** * 获取屏幕宽度(px) */
public static int getScreenWidth(Context context) {
return context.getResources().getDisplayMetrics().widthPixels;
}
/** * 获取屏幕宽度 */
public static DisplayMetrics getDisplayMetricsWidth(final Context pContext) {
return pContext.getResources().getDisplayMetrics();
}
public static int getDisplayWidthPixelsWidth(final Context pContext) {
return cn.jkwspersonal.util.ScreenUtils.getDisplayMetricsWidth(pContext).widthPixels;
}
public static int getDisplayHeightPixelsWidth(final Context pContext) {
return cn.jkwspersonal.util.ScreenUtils.getDisplayMetricsWidth(pContext).heightPixels;
}
public static float getDisplayXDpiWidth(final Context pContext) {
return cn.jkwspersonal.util.ScreenUtils.getDisplayMetricsWidth(pContext).xdpi;
}
public static float getDisplayYDpiWidth(final Context pContext) {
return cn.jkwspersonal.util.ScreenUtils.getDisplayMetricsWidth(pContext).ydpi;
}
public static float getDisplayDensityWidth(final Context pContext) {
return cn.jkwspersonal.util.ScreenUtils.getDisplayMetricsWidth(pContext).density;
}
public static int dipToPx(final Context pContext, final int pDip) {
return (int) (pDip * cn.jkwspersonal.util.ScreenUtils.getDisplayDensityWidth(pContext) + 0.5f);
}
}
边栏推荐
- ZUCC_编译语言原理与编译_实验06 07 语法分析 LL 分析
- Rescue system -- the application of read-write separation
- 中国芯片独角兽公司
- ZUCC_ Principles of compiling language and compilation_ Experiment 02 fsharp Ocaml language
- Qt导出PDF文件的两种方法
- [xinliu-s6 new model +sa 3-star Xinghai] the new two-way server of the third generation chip was launched and the product was updated~
- Three ways to uninstall Symantec Endpoint Protection Symantec
- App Startup
- Detailed explanation of etcd backup and recovery principle and actual record of stepping on the pit
- Five level classification of loans
猜你喜欢

ZUCC_ Principles of compiling language and compilation_ Experiment 05 regular expression, finite automata, lexical analysis

根据网络上的视频的m3u8文件通过ffmpeg进行合成视频

jwt(json web token)

Centos7安装jdk8以及mysql5.7以及Navicat连接虚拟机mysql的出错以及解决方法(附mysql下载出错解决办法)

ZUCC_ Principles of compiling language and compilation_ Experiment 02 fsharp Ocaml language

权限模型 DAC ACL RBAC ABAC

【微服务~Nacos】Nacos服务提供者和服务消费者

Redis cluster data skew

uniapp 热更新后台管理

Understanding of the concept of "quality"
随机推荐
List of Li Bai's 20 most classic poems
13 -- remove invalid parentheses
JUC个人简单笔记
ZUCC_ Principles of compiling language and compilation_ Experiment 05 regular expression, finite automata, lexical analysis
Redis cluster data skew
leetcode 1268. Search Suggestions System(搜索推荐系统)
ZUCC_编译语言原理与编译_实验08 语法分析 LR 分析
LabVIEW finds prime numbers in an array of n elements
Fund raising, trading and registration
Fundamentals of 3D mathematics [17] inverse square theorem
13 -- 移除无效的括号
【力扣10天SQL入门】Day3
New technology practice, encapsulating the permission application library step by step with the activity results API
pyQt 中 QMenu 响应
Two methods of QT exporting PDF files
[acnoi2022] not a structure, more like a structure
12-- merge two ordered linked lists
Easycvr invokes the interface parameter acquisition method and precautions of device video recording on the page
Maya re deployment
中国芯片独角兽公司