知识点
相关文章
更多最近更新
更多应用多个icon的对比
2019-03-02 01:02|来源: 网路
在给应用设计图标的时候,可能会遇到这样的需求,应用图标有老版和新版两种,而又想在桌面上同时显示这两个图标以对比效果。
一个应用本身只有一个自己的icon,在AndroidManifest.xml文件中的<application>的android:icon属性中可以进行设置。不过Android系统本身Intent的shortcut属性可以将启动一个intent的方式保存到Android系统的桌面上,并且还可以设置相应的图片。微信中将好友“添加到桌面”的功能应该就是用shortcut的intent来实现的。这里借助于shortcut intent来实现多个应用icon的对比。具体代码如下
一、设置shortcut intent的代码
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent shortcutIntent=new Intent(MainActivity.this,MainActivity.this.getClass()); final Intent icon1=new Intent(); icon1.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); icon1.putExtra(Intent.EXTRA_SHORTCUT_NAME, "原图标"); icon1.putExtra(Intent.EXTRA_SHORTCUT_ICON,BitmapFactory.decodeResource(getResources(), R.drawable.icon1)); icon1.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); sendBroadcast(icon1); final Intent icon2=new Intent(); icon2.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); icon2.putExtra(Intent.EXTRA_SHORTCUT_NAME, "新图标"); icon2.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.icon2)); icon2.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); sendBroadcast(icon2); }
二、AndroidManifest.xml文件中增加相应权限
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
三、用微信5.0和5.2的图标进行对比后的结果截图,可以看出5.2的图标要更扁平化并且显得更暗一些。
参考
shortcut intent的设定:http://stackoverflow.com/questions/3332753/desktop-icon-link
构造bitmap:http://stackoverflow.com/questions/4955268/how-to-set-a-bitmap-from-resource
扩展
(删除shortcut):http://www.cnblogs.com/yeqw1985/archive/2013/02/06/2907704.html
(launcher中多icon)http://www.icodelogic.com/?p=383
转自:http://www.cnblogs.com/jiangz/p/3532736
相关问答
更多-
我们可以为多个ios(ipad / iphone)应用程序使用相同的图标吗?(Can we use same icon for multiple ios (ipad/iphone) applications?)[2024-03-11]
就我所知,没有这样的规则。 事实上,App Store中的应用程序具有相同的图标,而其他应用程序的变体(例如,色调)很小。 除了需要批准的相关大小(需要提交的不同图标版本)之外,您应该考虑的唯一事项(但这与批准无关)是您的应用图标很吸引人,反映一些应用功能如何,并允许您的应用轻松识别。 如果您独特的图标设计符合您的这一原则,那就没问题。 There is no such rule, as far as I know. Indeed there are apps in the App Store that h ... -
这是我在评论中想到的代码。 请注意,我是在平板电脑上写的,所以我无法测试它。 希望它指出你正确的方向。 protected async override void OnBeforeExpand(TreeViewCancelEventArgs e) { await Task.Run(() => { if (!_expandedCache.Contains(e.Node.FullPath)) { ShellFileGetInfo.Folde ...
-
多个窗口,单个托盘图标(multiple windows, single tray icon)[2023-08-28]
你在问题中实际上回答了你自己的问题。 最好的办法是创建一个隐藏的窗口,只要需要托盘图标就可以存在。 您只需调用Shell_NotifyIcon()一次,并使用hWnd引用此隐藏窗口,然后让此窗口将消息发布到需要接收它们的各个窗口。 这也使您能够灵活决定跳过将消息发送到特定窗口,或者根据特定应用程序的要求,能够向每个窗口发送不同的消息。 You practically answered your own question in the question itself. The best thing to do ... -
如何创建多个fa-icon(How create a multiple fa-icon)[2023-05-18]
我相信你想要这样的东西? 1 大小可以改变与字体真棒类。 字体真棒堆叠通过将元素放置 ... -
如果您使用svg,则可以使用将设置fill属性的css类,例如: .svg-color{ fill: red; } 有时候svg笔画也会设置颜色,所以你的课程可能是: .svg-color{ fill: red; stroke: red; } 如果你想修改文件,你可以直接在里面执行: If you use svg you can use a css c ...
-
如何从多个位图创建一个System.Drawing.Icon?(How can I create one System.Drawing.Icon from multiple Bitmaps?)[2023-09-14]
要创建具有多个大小的Icon对象,您需要ico文件或ico文件流。 IconFactory的这个C#示例代码展示了如何在C#中创建这样的流形式的多个图像。 应该很容易更改此示例以使用Bitmap对象而不是BufferedImage对象。 To create an Icon object with multiple sizes you need an ico file or a stream of a ico file. This C# sample code of an IconFactory show h ... -
看到这个问题 一个Image只能有一个父级,所以它将从第一个MenuItem移动到第二个。 你可以像这样添加x:Shared属性
-
您缺少map: map创建标记时的map: map部分: for (i = 0; i < locations.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i][1], locations[i][2]), icon:'http://s7.postimg.org/wg6bu3jpj/pointer.png', map: map ...
-
如何更改多个活动的自定义窗口标题栏及其图标(How to change the customize Window title bar and its icon for multiple activities)[2021-12-08]
只需在自定义布局中设置imageview和textview id,并在特定的Activity中动态设置其值 ImageView image=(Imageview)getWindow().findViewById(your image view id); TextView title=(Textview)getWindow().findViewById(your image view id); set image.setImageResource(...); 和title.settext(title); 而 ... -
Honeycomb的启动器将使用可用的hdpi drawable作为mdpi设备上更高分辨率的mipmap。 mdpi图标应该仍然是48x48。 如果您想提供特定于xlarge屏幕的资源,您应该提供drawable-xlarge-mdpi,drawable-xlarge-hdpi等版本。 但是,如果您的目标是提供符合Android 3.0样式的图标,则可能需要使用v11(API级别11)作为您的限定符而不是xlarge。 (例如drawable-mdpi-v11,drawable-hdpi-v11) 在其他 ...