如何在Ubuntu手机中使得一个应用是全屏的应用

我们知道很多的开发者想把自己的应用设置为全屏的应用,这样可以使得应用能更多地占用屏幕的有效面积以使得自己的应用更好看。在默认的SDK的样板中,在应用的最上面,有一个“title”的地方占用很多的空间。对于一些应用来说,在主界面中,这个可能并不有用,但是对于使用PageStack的应用来说,这个区域显示一个向左的箭头以返回上一个页面的。 最近我也有这样的问题,我既想使用PageStack给予我的方便,又想拥有全屏的功能。在这篇文章中,我们来介绍如何做到全屏的应用。另外我们值得指出的是:我们的全屏的应用不能覆盖手机最上面的状态栏。

我们使用我们的Ubuntu SDK来创建一个最基本的应用(QML App with Simple UI)。Main.qml的内容如下:

import QtQuick 2.0
import Ubuntu.Components 1.1

/*!
    \brief MainView with a Label and Button elements.
*/

MainView {
    // objectName for functional testing purposes (autopilot-qt5)
    objectName: "mainView"

    // Note! applicationName needs to match the "name" field of the click manifest
    applicationName: "fullscreen.ubuntu"

    /*
     This property enables the application to change orientation
     when the device is rotated. The default is false.
    */
    //automaticOrientation: true

    // Removes the old toolbar and enables new features of the new header.
    useDeprecatedToolbar: false

    width: units.gu(50)
    height: units.gu(75)

    Page {
        title: i18n.tr("Simple")

        Column {
            spacing: units.gu(1)
            anchors {
                margins: units.gu(2)
                fill: parent
            }

            Label {
                id: label
                objectName: "label"

                text: i18n.tr("Hello..")
            }

            Button {
                objectName: "button"
                width: parent.width

                text: i18n.tr("Tap me!")

                onClicked: {
                    label.text = i18n.tr("..world!")
                }
            }
        }
    }
}

默认的情况下,我们运行我们的应用,显示如下:

  

从上面的图上可以看出来,无论是在手机或者是在手机上,有一个“Simple”的header在那里,占用一些空间。为了得到更多的空间,我们把Page的title设为空,也即:

import QtQuick 2.0
import Ubuntu.Components 1.1

/*!
    \brief MainView with a Label and Button elements.
*/

MainView {
    // objectName for functional testing purposes (autopilot-qt5)
    objectName: "mainView"

    // Note! applicationName needs to match the "name" field of the click manifest
    applicationName: "fullscreen.ubuntu"

    /*
     This property enables the application to change orientation
     when the device is rotated. The default is false.
    */
    //automaticOrientation: true

    // Removes the old toolbar and enables new features of the new header.
    useDeprecatedToolbar: false

    width: units.gu(50)
    height: units.gu(75)

    Page {
        title: i18n.tr("")

        Column {
            spacing: units.gu(1)
            anchors {
                margins: units.gu(2)
                fill: parent
            }

            Label {
                id: label
                objectName: "label"

                text: i18n.tr("Hello..")
            }

            Button {
                objectName: "button"
                width: parent.width

                text: i18n.tr("Tap me!")

                onClicked: {
                    label.text = i18n.tr("..world!")
                }
            }
        }
    }
}

重新运行我们的应用:

  

我们显然可以看到,“title”区域不见了。应用所占用的区间更大了。

不想使用PageStack的应用来说,我们也不必使用Page。我们可以直接使用如下的方法直接占用整个有效的屏幕区域:

import QtQuick 2.0
import Ubuntu.Components 1.1

/*!
    \brief MainView with a Label and Button elements.
*/

MainView {
    // objectName for functional testing purposes (autopilot-qt5)
    objectName: "mainView"

    // Note! applicationName needs to match the "name" field of the click manifest
    applicationName: "fullscreen.ubuntu"

    /*
     This property enables the application to change orientation
     when the device is rotated. The default is false.
    */
    //automaticOrientation: true

    // Removes the old toolbar and enables new features of the new header.
    useDeprecatedToolbar: false

    width: units.gu(50)
    height: units.gu(75)

    Rectangle {
        anchors.fill: parent
        color: "red"
    }

}

  

通过这样的方法,我们就可以得到全屏的应用了。

时间: 2024-08-28 13:44:20

如何在Ubuntu手机中使得一个应用是全屏的应用的相关文章

如何在Ubuntu手机上实现一个FileDialog

前一段时间,有个开发者问我能否在Ubuntu手机中使用QtQuick.Dialogs来实现FileDialog.目前在手机上没有Qt这个库的实现.最主要的原因是它不使用unit grid的方式来布局,所以在真的手机上显得非常小.那么我们怎么才能实现同样的功能呢? 我们首先来查看一下我们的Ubuntu Qt所提供的API Dialog.这里我们有提供一个Dialog的control.我们可以仿照上面的例程来写出我们所需要的例程.另外,我们也需要使用另外一个APIFolderListModel.通过

如何在Ubuntu手机中使用前置照相机

我们可以在Ubuntu QML的API文档中看到Camera的用法,但是里面没有写到任何的前置Camera的调用方法.对于一些应用来说,前置Camera的使用是重要的.我们必须使用Qt C++代码来实现这个功能.在这篇文章中,我们来介绍如何使用Ubuntu手机中的前置照相机. 1)创建一个最基本的QML应用         这样我们就生成了一个含有plugin的项目. 2)在项目中加入CameraSelector来选择照相机 为了能够调用Camera的一些API,我们在plugin中加入如下的C

如何在Ubuntu手机中监测网络的连接信息

我们知道对于很多的网路应用来说,网路的连接信息对于我们来说非常重要.我们有必要对网路的连接信息进行监测.一旦网路连接断开,我们需要提醒用户或做一些处理.在Ubuntu平台上,我们可以使用connectivity库来查看. 我们可以利用SDK的模版来创建一个最简单的QML应用.因为我们要使用connectivity,所以我们必须加入"connectivity"的security policy. 在我们的开发者网站上虽然也有NetworkStatus的介绍,但是可能并不是很全,我们可以使用

如何在 javascript / js 中 建立一个map

建立map的方式(其实用的是json实现方式) var a = {}; a["key1"] = "value1"; a["key2"] = "value2"; 既然是个map就有检索某个键是否存在的方法,这样写 if ("key1" in a) { // something } else { // something else } 简单的一句话声明map里面的key和value的方式: var a = {'

在ubuntu linux 中编写一个自己的python脚本

在ubuntu linux 中编写一个自己的简单的bash脚本. 实现功能:终端中输入简单的命令(以pmpy为例(play music python),为了区别之前说的bash脚本添加了py后缀),来实现音乐的播放.注:本人ununut中安装了audacious,所以就以audacious为例,来实现音乐的播放. 第一步:进入一个目录,最好是自己特别选定的,如果用文件浏览器可以新建一个名为pmpy空白文档文件:如果是用终端可以输入命令:vi pmpy(可能会因为位置问题,需要添加sudo) 第二

如何在CAD图纸中插入一个Excel表格?

大家都知道在CAD设计建筑行业经常要使用到CAD绘图技巧,在日常的工作中,我们经常使用CAD编辑器软件对CAD图纸进行一些编辑,但是如果我们想要在CAD图纸中插入一个Excel表格应该具体怎么操作呢?又如何在CAD图纸中插入一个Excel表格?所以本篇教程就教教大家怎么使用迅捷CAD编辑器在CAD图纸中插入一个Excel表格,希望可以帮助到你们. 第一步:首先打开电脑,在电脑桌面上任意的打开一个浏览器,在浏览器的搜索框中搜索迅捷CAD编辑器,点击下载安装最新版本的CAD编辑器. 第二步:双击打开

如何在CAD编辑器中插入一个WPS公式?

如何在CAD编辑器中插入一个WPS公式?在编辑器CAD图纸的过程中,肯定会有许多的问题,比如说如果想要在CAD编辑器插入一个公式要怎么插,在CAD软件中插入一个WPS公式是非常日常的操作,像设计师和建筑工程师们在设计图纸中都会遇到的操作,那么如何在CAD编辑器中插入一个WPS公式,具体要怎么来操作完成了?下面就来教教大家在迅捷CAD编辑器专业版中的具体操作方法,想要了解的朋友就一起来看看吧! 步骤一:打开浏览器,在浏览器中搜索迅捷CAD编辑器,然后鼠标点击官网并进行下载安装最新版本的CAD编辑器

IOS写一个可以支持全屏的WebView

这样来写布局 一个TitleView作为顶部搜索栏: @implementation TitleView - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code [self initTilte]; } return self; } -(void)initTilte{ UITextField* field = [[UITextField al

一个简单的全屏图片上下打开显示网页效果

打包下载地址:http://download.csdn.net/detail/sweetsuzyhyf/7602105 上源码看效果: <!DOCTYPE html> <html> <head> <title></title> <style> body { margin: 0; padding: 0; } .wrap { overflow: hidden; position: fixed; z-index: 99999; width: