当前位置:网站首页>Today's headline adaptation scheme code
Today's headline adaptation scheme code
2022-06-26 09:57:00 【Bai Ze】
Today's headline adaptation scheme code
/**
* Today's headline adaptation The final version Adaptation ratio Take width as latitude ,360dp To fit
*/
private static float sNoncompatDensity;
private static float sNoncompatScaledDensity;
private static void setCustomDensity(@NonNull Activity activity, @NonNull final Application application) {
final DisplayMetrics appDisplayMetrics = application.getResources().getDisplayMetrics();
if (sNoncompatDensity == 0) {
sNoncompatDensity = appDisplayMetrics.density;
sNoncompatScaledDensity = appDisplayMetrics.scaledDensity;
application.registerComponentCallbacks(new ComponentCallbacks() {
@Override
public void onConfigurationChanged(Configuration newConfig) {
if (newConfig != null && newConfig.fontScale > 0) {
sNoncompatScaledDensity = application.getResources().getDisplayMetrics().scaledDensity;
}
}
@Override
public void onLowMemory() {
}
});
}
final float targetDensity = appDisplayMetrics.widthPixels / 360;
final float targetScaledDensity = targetDensity * (sNoncompatScaledDensity / sNoncompatDensity);
final int targetDensityDpi = (int) (160 * targetDensity);
appDisplayMetrics.density = targetDensity;
appDisplayMetrics.scaledDensity = targetScaledDensity;
appDisplayMetrics.densityDpi = targetDensityDpi;
final DisplayMetrics activityDisplayMetrics = activity.getResources().getDisplayMetrics();
activityDisplayMetrics.density = targetDensity;
activityDisplayMetrics.scaledDensity = targetScaledDensity;
activityDisplayMetrics.densityDpi = targetDensityDpi;
}
边栏推荐
- 存储过程测试入门案例
- 爬虫相关文章收藏:pyppeteer 、Burpsuite
- The basis of C language grammar -- pointer (multidimensional array, function, summary) learning
- thymeleaf中抽取公共片段
- LeetCode 接雨水系列 42.(一维) 407.(二维)
- Force buckle ----- remove the maximum and minimum values from the array
- How to find and install the dependent libraries of Debian system
- install opencv-contrib-dev to use aruco code
- 国际化配置
- Redis notes (15) - Pipeline (the client packages and sends batch commands to save network overhead)
猜你喜欢

WGCLOUD的web ssh服务端口是多少

mysql 数据库字段查询区分大小写设置

VI summary of common commands

Logview Pro can be used if the log is too large

Force buckle ----- remove the maximum and minimum values from the array

Redis notes (14) - persistence and data recovery (data persistence RDB and AOF, data recovery, mixed persistence)

Basic grammar of C language -- pointer (character, one-dimensional array) learning

Redis 新手入门

十万行事务锁,开了眼界了。

國際化配置
随机推荐
TensorFlow遇到的各种错误
online trajectory generation
2021-11-12 vrep vision sensor configuration
[trajectory planning] testing of ruckig Library
Extracting public fragments from thymeleaf
Notes on sports planning on November 22, 2021
Introduction to stored procedure testing
DAY 3 数组,前置后置,字符空间,关键词和地址指针
Mysql database operation commands (constantly updated)
Js--- get the data with the same key value in the object array to get a new array
Tensorflow dynamically allocates video memory
thinkphp6.0的第三方扩展包,支持上传阿里云,七牛云
mysql学习总结
The basis of C language grammar -- function definition learning
jar版本冲突问题解决
install realsense2: The following packages have unmet dependencies: libgtk-3-dev
Meaning of go runtime
测试须知——常见接口协议解析
2021-11-29 quintic polynomial of trajectory planning
logback