屏幕分辨率问题
通过编程,我如何知道我的屏幕的屏幕分辨率
。 一旦运行应用程序,它应该会找出以 dp 和像素
为单位的屏幕分辨率
。
怎样才能做到这一点呢?
谢谢
Through programming how can i know whats the screen resolution
of my screen.
As soon as run the app it should find out the screen resolution
in dp and in pixel
.
How can do that?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 DisplayMetrics 从您的设备获取屏幕信息。
一些示例代码,
编辑:
Use, DisplayMetrics to get screen info from your device.
Some sample code,
EDIT:
使用下面的代码来获取屏幕宽度和宽度height
添加
另外,不要忘记在清单中 。
minSdkVersion
的值等于或大于 4。但是如果您的minSdkVersion
是 3,那么您的targetSdkVersion
应该等于或大于 4才能获得正确的值宽度和高度。
Use below code to get screen width & height
Also dont forget to add
<uses-sdk android:minSdkVersion="4"/>
in your manifest. The value of
minSdkVersion
be equal or above 4. But if yourminSdkVersion
is 3 then yourtargetSdkVersion
should be equal or above 4to have correct value of width & height.