java - 特定设备的 Android 布局未显示
问题描述
我为我的两个设备准备了两种不同的布局。首先我用这段代码检查了宽度和高度:
Display display = getWindowManager().getDefaultDisplay();
DisplayMetrics outMetrics = new DisplayMetrics ();
display.getMetrics(outMetrics);
float density = getResources().getDisplayMetrics().density;
float dpHeight = outMetrics.heightPixels / density;
float dpWidth = outMetrics.widthPixels / density;
它告诉我,第一个设备有360dp width and 592dp height
,第二个360dp width and 692dp height
。所以我在这样的文件夹layout-w360dp-h592dp
和layout-w360dp-h692dp
.
事实证明,这些设备不使用它们专用的布局。360dp width and 592dp height
设备使用默认布局,360dp width and 692dp height
设备使用360dp width and 592dp height
.
问题出在哪里?先感谢您!
解决方案
推荐阅读
- php - 服务器和客户端上的 Javascript/CSS 加密
- redux-saga - 在 Redux Saga 中按顺序调用动作(同步)
- java - 多线程中的对象锁定
- python - 如何使用 RSAPublicKey 字段腌制 namedtuple 子类
- json - 在 Angular 中使用嵌套的 JSON 数据
- android-studio - Android Studio 3.5 Canary 7:“应用代码更改”已禁用
- c++ - 当调度策略为 SCHED_RR 时,pthread 临界区中的经过时间峰值可能是什么原因?
- node.js - 带有嵌套描述的订单
- reactjs - 将路由器链接放在滑动侧边栏中
- vb.net - 将当前日期与时间格式化为日期,而不是字符串