当前位置:网站首页>获取屏幕宽高工具类
获取屏幕宽高工具类
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_ Principles of compiling language and compilation_ Experiment 04 language and grammar
- "Adobe international certification" Photoshop software, about drawing tutorial?
- Paper notes: multi label learning dm2l
- Matlab求解线性方程组Ax=b
- Scénarios d'utilisation de la promesse
- os. path. Pits encountered during the use of join()
- 日本大阪大学万伟伟研究员介绍基于WRS系统机器人的快速集成方法和应用
- QPS, TPS, concurrent users, throughput relationship
- ZUCC_ Principles of compiling language and compilation_ Experiment 08 parsing LR parsing
- JS to get the last element of the array
猜你喜欢

How to improve the customer retention rate in the operation of independent stations? Customer segmentation is very important!

ZUCC_ Principles of compiling language and compilation_ Experiment 01 language analysis and introduction

2022 tea artist (intermediate) work license question bank and online simulation examination

Small sample fault diagnosis - attention mechanism code - Implementation of bigru code parsing

io模型初探

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

JUC personal simple notes

uniapp 热更新后台管理

Pat 1157: school anniversary

New technology practice, encapsulating the permission application library step by step with the activity results API
随机推荐
The article takes you to understand the security of Windows operating system and protect your computer from infringement
Pyqt common system events
Getting started with ffmpeg
Shell basic operator -- arithmetic operator
Detailed explanation of etcd backup and recovery principle and actual record of stepping on the pit
Rust procedure macro simply imitates Lombok function
String转Base64
Qt源码分析--QObject(2)
2021-06-25: a batch of strings consisting only of lowercase letters (a~z) are put
根据网络上的视频的m3u8文件通过ffmpeg进行合成视频
Vscode install the remote -wsl plug-in to connect to the local WSL
MATLAB Camera Calibrator相机标定
日本大阪大学万伟伟研究员介绍基于WRS系统机器人的快速集成方法和应用
权限模型 DAC ACL RBAC ABAC
Centos7安装jdk8以及mysql5.7以及Navicat连接虚拟机mysql的出错以及解决方法(附mysql下载出错解决办法)
Export MySQL database to xxx SQL, set xxx The SQL file is imported into MySQL on the server. Project deployment.
李白最经典的20首诗排行榜
普通token
JS to get the last element of the array
Tencent cloud ASR product PHP realizes real-time voice authentication request