当前位置:网站首页>Get screen width and height tool class
Get screen width and height tool class
2022-06-24 08:41:00 【Simon66991】
public class ScreenUtils {
/** * Get screen height (px) */
public static int getScreenHeight(Context context) {
return context.getResources().getDisplayMetrics().heightPixels;
}
/** * Get screen height */
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);
}
/** * Get screen width (px) */
public static int getScreenWidth(Context context) {
return context.getResources().getDisplayMetrics().widthPixels;
}
/** * Get screen width */
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);
}
}
边栏推荐
- IIS build wordpress5.7 manually
- Shell basic operators -- relational operators
- Redis的Cluster集群数据倾斜
- There was an error checking the latest version of pip
- Common date formatter and QT method for obtaining current time
- [explain the difference between operation and maintenance and network engineering]
- Opencv实现图像的基本变换
- liunx 更改 vsftpd 的端口号
- Common misconceptions in Tencent conference API - signature error_ code 200003
- Easycvr invokes the interface parameter acquisition method and precautions of device video recording on the page
猜你喜欢

liunx服务器 telnet 带用户名 端口登陆方法

js中通过key查找和更新对象中指定值的方法
![[untitled]](/img/94/792e8363dbfe67770e93b0dcdc8e72.png)
[untitled]

独立站运营中如何提升客户留存率?客户细分很重要!

Redis的Cluster集群数据倾斜

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

jwt(json web token)

5 minutes, excellent customer service chat handling skills

ZUCC_编译语言原理与编译_实验06 07 语法分析 LL 分析

Base64编码详解及其变种(解决加号在URL变空格问题)
随机推荐
Several ways you can't move zero (sequel)
利用sonar做代码检查
[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~
xtrabackup做数据备份
Video Fusion communication has become an inevitable trend of emergency command communication. How to realize it based on easyrtc?
Opencv get (propid) common values
Micro build low code online "quick registration applet" capability
Base64编码详解及其变种(解决加号在URL变空格问题)
Scheduled database backup script
【力扣10天SQL入门】Day3
Scénarios d'utilisation de la promesse
Smart power plant: how to make use of easycvr to build a safe, stable, green and environment-friendly intelligent inspection platform
liunx 更改 vsftpd 的端口号
Introduction to NC machine tool programming [G-code]
成为IEEE学生会员
Blue screen error UNMOUNTABLE boot volume of the solution
MySQL 因字符集问题插入中文数据时提示代码 :1366
dataX使用指南
Permission model DAC ACL RBAC ABAC
获取屏幕宽高工具类