从Ubuntu Screen API得到屏幕信息及手机的方向信息
2016-03-22 17:08
1071 查看
我们知道对于一些手机应用来说,能够得到屏幕的尺寸信息已经屏幕的方向,那么对我们的应用的布局非常中.我们可以通过对这个事件的感知,进一步来对我们的应用的布局来重新调整.
下面我们来通过一个简单的例程来显示在Ubuntu
Screen API中有那些信息.
在我们的MX4手机上运行我们的应用:
从上面的信息中,我们可以看出来,我们的Screen API给出的所有的信息.细心的开发者将会发现这里得到的信息和我们之前在文章"如何得到屏幕和可用显示区域的大小尺寸及运用分辨率无关的编程"得到的屏幕尺寸是一样的.
整个项目的源码在:https://github.com/liu-xiao-guo/screenapi
下面我们来通过一个简单的例程来显示在Ubuntu
Screen API中有那些信息.
Main.qml
import QtQuick 2.4 import Ubuntu.Components 1.3 import QtQuick.Window 2.2 MainView { // objectName for functional testing purposes (autopilot-qt5) objectName: "mainView" // Note! applicationName needs to match the "name" field of the click manifest applicationName: "screen.liu-xiao-guo" width: units.gu(60) height: units.gu(85) property var orientations: ["PrimaryOrientation", "PortraitOrientation", "LandscapeOrientation","", "InvertedPortraitOrientation","", "","", "InvertedLandscapeOrientation" ] Page { title: i18n.tr("screen") Column { anchors.centerIn: parent spacing: units.gu(2) Label { text: "desktopAvailableHeight: " + Screen.desktopAvailableHeight } Label { text: "devicePixelRatio: " + Screen.devicePixelRatio } Label { text: "desktopAvailableWidth: " + Screen.desktopAvailableWidth } Label { text: "height: " + Screen.height } Label { text: "width: " + Screen.width } Label { text: "name: " + Screen.name } Label { text: "orientation: " + orientations[Screen.orientation] } Label { text: "primaryOrientation: " + orientations[Screen.primaryOrientation] } Label { text: "orientationUpdateMask: " + Screen.orientationUpdateMask } Label { text: "pixelDensity: " + Screen.pixelDensity } } } }
在我们的MX4手机上运行我们的应用:
从上面的信息中,我们可以看出来,我们的Screen API给出的所有的信息.细心的开发者将会发现这里得到的信息和我们之前在文章"如何得到屏幕和可用显示区域的大小尺寸及运用分辨率无关的编程"得到的屏幕尺寸是一样的.
整个项目的源码在:https://github.com/liu-xiao-guo/screenapi
相关文章推荐
- 多个线程如何操作同一个epoll fd
- web.xml 中的listener、 filter、servlet 加载顺序及其详解
- 汇编学习-补码
- 133个Java面试问题列表
- 什么是真正的工作到位
- 自定义ContentProvider
- PendingIntent的解读。
- 第六届CCF软件能力认证
- BaseAdapter的三样式 IV
- Move方法与CharacterController才能配合使用
- 【matlab】:matlab的输入和输出
- Redis 数据持久化(一)
- Thttpd_上传文件
- iOS企业版发布 HTTPS证书以及服务器设置
- windows bat脚本for循环中对变量循环赋值
- LinuxC(Unix/Linux系统简介/开发工具)
- MQTT+ApolloServer实现Android的消息推送功能
- Nginx 作为 WebSockets 代理
- 数据结构(Data Structure)——0、数据类型
- mysql innodb 数据安全性分析