当前位置:网站首页>获取屏幕宽高工具类
获取屏幕宽高工具类
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);
}
}
边栏推荐
- Take my brother to do the project. It's cold
- ZUCC_ Principles of compiling language and compilation_ Experiment 01 language analysis and introduction
- 【力扣10天SQL入门】Day3
- Common CVM transcribes audio using virtual sound card
- App Startup
- 5分钟,客服聊天处理技巧,炉火纯青
- Robot acceleration level task priority inverse kinematics
- List of Li Bai's 20 most classic poems
- Scénarios d'utilisation de la promesse
- Use cpulimit to free up your CPU
猜你喜欢

js中通过key查找和更新对象中指定值的方法

5 minutes, excellent customer service chat handling skills

List of Li Bai's 20 most classic poems

ZUCC_编译语言原理与编译_实验04 语言与文法
![Fundamentals of 3D mathematics [17] inverse square theorem](/img/59/bef931d96883288766fc94e38e0ace.png)
Fundamentals of 3D mathematics [17] inverse square theorem

权限模型 DAC ACL RBAC ABAC

新技术实战,一步步用Activity Results API封装权限申请库

Longhorn installation and use

ZUCC_ Principles of compiling language and compilation_ Experiment 04 language and grammar

JUC个人简单笔记
随机推荐
ZUCC_编译语言原理与编译_实验06 07 语法分析 LL 分析
QTimer定时器不起作用的原因
日本大阪大学万伟伟研究员介绍基于WRS系统机器人的快速集成方法和应用
ZUCC_编译语言原理与编译_实验03 编译器入门
ZUCC_编译语言原理与编译_实验01 语言分析与简介
"Adobe international certification" Photoshop software, about drawing tutorial?
Two methods of QT exporting PDF files
orb slam build bug: undefined reference to symbol ‘_ZN5boost6system15system_categoryEv‘
Cloudbase database migration scheme
Promise的使用場景
[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~
List of Li Bai's 20 most classic poems
【无标题】
jwt(json web token)
New technology practice, encapsulating the permission application library step by step with the activity results API
12-- merge two ordered linked lists
ZUCC_ Principles of compiling language and compilation_ Big job
How to configure networkpolicy for nodeport in kubernetes
OpenCV get(propId) 常用的值
05 Ubuntu installing mysql8