QT 仿android launcher
QT 在嵌入式设备的图形界面开发上用的比较多,现在的嵌入式设备主流用的是android,QT的桌面又没有android那么好用,最近在做QT 的一些项目,于是想先用QT仿一个android 的luancher。
整体思路分两步来实现,一是布局,二是事件响应。
一.布局
1. 参考android launcher setContentView(launcher.xml)的设置流程,先创建LauncherRootView 的布局
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:layout_column="match_parent"
android:layout_row="match_parent"
android:layout_gravity="center"
launcher:pageIndicator="@id/page_indicator" />
3.再参考 android launcher 的setupViews()函数设置workspace 的布局,android 的workspace.xml 是如下的。这里增加一个icon的属性,以便设置图标。
default_workspace.xml
快捷方式说明
//程序快捷键属性标签 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
有时间的时候再维护更新。
更多相关文章
- 深入解析Android的自定义布局
- Android的布局和Intent笔记和常用实例
- Android实现动态改变app图标的示例代码
- Android 布局属性 Android:layout_weight 总结
- android 五大布局文件
- Android TabHost布局
- RelativieLayout布局中的android:gravity="center"属性
- Android Layout.xml布局属性