QT 仿android launcher

QT 在嵌入式设备的图形界面开发上用的比较多,现在的嵌入式设备主流用的是android,QT的桌面又没有android那么好用,最近在做QT 的一些项目,于是想先用QT仿一个android 的luancher。

整体思路分两步来实现,一是布局,二是事件响应。

一.布局

 

1. 参考android launcher setContentView(launcher.xml)的设置流程,先创建LauncherRootView 的布局

<com.qt.launcher.LauncherRootView
    android:id="@+id/launcher"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"        <!-- The workspace contains 5 screens of cells -->
        <!-- DO NOT CHANGE THE ID -->
        <com.qt.launcher.Workspace
            android:id="@+id/workspace"
            android:layout_column="match_parent"
            android:layout_row="match_parent"
            android:layout_gravity="center"
            launcher:pageIndicator="@id/page_indicator" />
</com.qt.launcher.LauncherRootView>

3.再参考 android launcher 的setupViews()函数设置workspace 的布局,android 的workspace.xml 是如下的。这里增加一个icon的属性,以便设置图标。

default_workspace.xml

快捷方式说明

<favorite                         //程序快捷键属性标签
    launcher:className="com.apical.MainActivity"//该应用的类,点击图标时,需要启动的类
    launcher:packageName="com.apical.radio"     //该应用的包名
    launcher:screen="1"                   //第1屏,0-4屏共5屏
    launcher:x="0"                         //图标X位置,左上角第一个为0,向右递增,0-4共5个
    launcher:y="0"                       //图标Y位置,左上角第一个为0,向下递增,0-2共3个
    launcher:spanX="3"                          //在x方向上所占格数
    launcher:spanY="2" 						        //在y方向上所占格数
    launcher.icon="bitmap/名字" 
/>

4. 参考BubbleTextView 创建我们QT的 ImageButton。

二.事件响应

添加我们的事件响应函数。

 

代码上传到github。

https://github.com/Mrxiang/QLauncher

有时间的时候再维护更新。

 

 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值