Changing the Cordova app icon
来源:互联网 发布:英语网络 编辑:程序博客网 时间:2024/06/15 06:01
http://intown.biz/2014/03/07/changing-the-cordova-app-icon/
It seems that many Cordova tasks, even fundamental ones, require some degree of research. In this case, I first found a solution that was “close enough”, and then found a better one. Both are shown here.
The goal here is to use your own custom icon instead of the default icon.
The Sub-optimal Way
1. Find the drawable directory, and place the icon in it (Yes, I see there are actually 5 drawable directories. For now I only care about one.)
2. Find the AndroidManifest file, and modify it to point to your file. Note: leave out the extension of the icon file.
<application android:hardwareAccelerated=”true” android:icon=”@drawable/myIcon”android:label=”@string/app_name”>
3. Compile and run.
The Better Way
This way is better because as a best practice, it’s good to keep everything in the platforms/android directory generic. Ideally you should be able to check out the code in a clean environment, use the cordova add platform android command and be ready to go.
This time we don’t have to change the manifest, because we’re just replacing the icon.png file by copying over it.
We achieve this using hooks, which are custom commands that run during the build process. This particular command copies the icon files into their appropriate directories. Here’s the process:
- Create a folder for hooks as shown in the image. We’ll focus on the “after_prepare” point of the build, but there are a number of other points where you can run commands, as detailed here.
- Create a configuration directory in the root, as shown. You could really put these files anywhere, if you want to use your own organizational structure.
- Download these hooks: http://www.mooreds.com/sample-hooks.tar.gz. You’ll only need the one called 030_resource_files.js, though the others could come in handy too. They are explained by Dan Moore on Devgirl’s excellent blog.
- Tweak the file to suit your own nefarious needs.
Next time you build, your files should be copied into the appropriate places automatically. And you still don’t need to check in your platforms directory!
PS:我找到的一个在线生成app icon的网站:
http://romannurik.github.io/AndroidAssetStudio/icons-launcher.html#foreground.space.trim=1&foreground.space.pad=0&foreColor=33b5e5%2C0&crop=0&backgroundShape=bevel&backColor=ffffff%2C100- Changing the Cordova app icon
- Build the App--cordova编译app
- Clicking the dock icon to show the app on Mac
- APP Icon
- APP Icon
- ERROR ITMS-90717: "Invalid App Store Icon. The App Store Icon in the asset catalog in ‘***.app' can'
- Changing Status pane text and icon
- Changing Status pane text and icon
- Cordova官方插件 -- Icon + SplashScreen
- The app icon set "AppIcon" has an unassigned child告警
- Designing the Application Architecture - changing web.config for azure app fabric settings
- ios 提交 App Store Error Problem with Icon.png (Icon specified in the Info.plist not found under the t
- The changing marketplace of bioinformatics
- Changing the Login Screen Appearance
- Changing the Favicon in PeopleSoft
- Changing the Database Archiving Mode
- Changing the ID of Dynamixel
- Solaris 11: changing the hostname
- C++ STL简介
- C++学习的50条忠告
- Word Break II 求把字符串拆分为字典里的单词的所有方案 @LeetCode
- JCIP_4_01_扩展现有安全类_客户端加锁
- 今日作息及食谱(8.13)
- Changing the Cordova app icon
- 如果是作为客户端的HTTP+JSON接口工程,没有JSP等view视图的情况下,使用Jersery框架开发绝对是第一选择。而在基于Spring3 MVC的架构下,对HTTP+JSON的返回类型也有很好
- Sublime Text 2 Error trying to parse settings
- 使用PhoneGap Build 将web applications打包成native mobile applications
- 编写一个标准strcpy函数
- 如何构建优质代码
- 最完整最简洁的JavaScript基础教程
- 2.1.9 3Sum Closest
- 关于算法面试中涉及Binary Tree的问题