假设没有git工具。能够点击master。
刚好近期lollipop的Launcher源代码也更新了。和之前的Launcher3会有一些差别,只是不大,倒入过程大同小异。 git下载: 压缩包下载: 下载完后解压,文件夹例如以下: 接着导入eclipse。由于Launcher3的某些新特性。须要将build target设置为API level 19(不是必须,为了方便研究起见。Launcher3的源代码最低能够兼容大API16)。然后导入项目所依赖的类库,这个地方分为三种情况,一是导入v4包,手动加入一个libs文件夹,将v4包加进去。二是须要protocol buffers。到https://android.googlesource.com/platform/external/protobuf.git下载,最好打成jar包。然后放在libs文件夹下。三是加入BackupProtos.java这个类。
能够从上一步中获取。英文好的朋友能够看一下以下的步骤:
git clone https://android.googlesource.com/platform/packages/apps/Launcher3
Import existing code into Eclipse (Android Project from Existing Code)Change the project build target to API level 19Add Android support librariesBuild protocol buffers JAR from AOSP source. You will actually need to build the protoc binary as well. You need to know how to use ‘make’ have gcc available for the protoc binary, and Maven for the JAR: https://android.googlesource.com/pla…l/protobuf.gitUse protoc binary built from step above to generate the BackupProtos.java file:protoc –javanano_out=src/ -I protos protos/backup.proto
Rename the Android package (Android Tools->Rename Application Package) to one of your choiceAdd min SDK in a new ‘uses-sdk’ element in AndroidManifest.xml (works down to API level 17 without too many complaints in Lint, obviously stick to 19 to play it safe).Clean and run. BIND APP WIDGETS error can be ignoredFabio Lo Brutto:https://plus.google.com/+FabioLoBrutto/posts/KJeyKMBHVT7
导完后的文件夹结构例如以下: 假设想做一个自己的Launcher,那么须要把包名改一下。研究的话就没有必要了。最后执行,截图例如以下:
关于Launcher最复杂的东西不在于怎样显示应用程序、Widget、文件夹等功能。而是自己定义View方面,由于基本上Launcher的View都是自己定义的。并且代码都非常多。理解起来不是那么简单。所以说,假设把Launcher里面的自己定义的View掌握了,那么对Launcher也就基本掌握了。
因此,学习重点应该集中在自己定义View上。
今后会持续更新关于Launcher3开发方面的文章,在做Launcher开发的朋友能够一起交流。转载于:https://www.cnblogs.com/bhlsheji/p/5303624.html
相关资源:Launcher3 最新源码