如何从应用程序更改启动器图标及其标签 [英] How to change launcher icon and it's label from the application

查看:78
本文介绍了如何从应用程序更改启动器图标及其标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Android应用程序运行时中更改启动器图标及其标签?(如果可能)
我的意思是在 AndroidManifest.xml 中定义的属性: android:icon android:label .我想用我从相机拍摄的图像代替它.

How can I change the launcher icon and its label from my application runtime in Android? (if it is possible)
I mean the properties defined in AndroidManifest.xml: android:icon and android:label. I want to replace it by the image I take from the camera.

推荐答案

编辑:您最初的答案未指定您要在运行时执行此操作.这行下面是编译之前的操作方法.至于在运行时以编程方式进行操作:

your original answer didn't specify you wanted to do it at runtime. Below the line is how to do it before it compiles. As for doing it programmatically at runtime:

来自此答案:

除非通过软件升级,否则您不能在签名和密封的APK中更改清单或资源.

You cannot change the manifest or the resource in the signed-and-sealed APK, except through a software upgrade.

但是,被接受的答案也指出了骇客"或某种作弊方式(我想).我还没有测试过,但是有一个消息源可供您查看.

But also, the accepted answer figured out a "hack" or some cheating way to do it (I presume). I haven't tested it, but there is a source for you to check out.

或者,此链接显然描述了如何使用小工具"方法.

Or, this link apparently describes how to do this using the "widget" approach.

所以可以说您的清单是这样的:

So lets say your manifest was like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="yourPackage"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

     ...

您可以通过将图像放入可绘制文件夹中来更改启动器图标:

You would change the launcher icon by putting images into your drawable folders:

Project folder --> res --> all the drawables

然后,您将 android:icon ="@ drawable/ic_launcher" 更改为 android:icon ="@ drawable/whateverTheNameOfTheImageIsYouPutInTheDrawablesFolders"

要更改标签:

打开位于以下位置的 strings.xml 文件:

Open up your strings.xml file which is located:

Project folder --> res --> values --> strings.xml

并查找如下所示的字符串:

And look for the string that looks like this:

<string name="app_name">Your App Name</string>

然后只需将您的应用名称更改为您想要的标签名称即可.

And just change Your App Name to be whatever you want the label to be.

摘要:

android:icon ="@ drawable/ic_launcher" 确定启动器图标,因此只需将图像添加到可绘制文件夹中,然后将 ic_launcher 更改为图像名称即可您想成为图标.

android:icon="@drawable/ic_launcher" determines your launcher icon, so just add images to the drawable folders and change ic_launcher to whatever the name of image is that you want to be the icon.

android:label ="@ string/app_name" 确定您的标签",因此只需查找 app_name (因为标签引用了 @ string/app_name )添加到您的 strings.xml 文件中,然后更改 app_name 的内容.

android:label="@string/app_name" determines your "label" so just look for app_name (because the label is referenced to @string/app_name) in your strings.xml file and change the contents of app_name.

这篇关于如何从应用程序更改启动器图标及其标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆