簡體   English   中英

無法更改Android應用的默認圖標?

[英]Can't change the default icon of Android app?

我正面臨一個問題。 我已經使用phonegap,cordova和eclipse將javascript應用程序轉換為Android應用程序。 該應用程序很酷。

但問題是,它總是將cordova圖標顯示為應用程序圖標 我替換了"project/res"文件夾中的所有圖標。 但它仍然只顯示默認圖標?

我用谷歌搜索它,然后才知道我必須在清單文件中進行更改。 所以,我在AndroidManifest.XML更改了代碼,

android:icon="@drawable/icon"

“icon”是我的圖像名稱。

這里有什么問題? 為什么我沒有自己的偶像? 我是這個Android環境的新手。

我按照這篇文章http://smartgap.wordpress.com/2012/08/11/customizing-launch-icon-on-eclipsephonegap-application/

我的清單文件:

<?xml version="1.0" encoding="utf-8"?>
<!--
       Licensed to the Apache Software Foundation (ASF) under one
       or more contributor license agreements.  See the NOTICE file
       distributed with this work for additional information
       regarding copyright ownership.  The ASF licenses this file
       to you under the Apache License, Version 2.0 (the
       "License"); you may not use this file except in compliance
       with the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

       Unless required by applicable law or agreed to in writing,
       software distributed under the License is distributed on an
       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
       KIND, either express or implied.  See the License for the
       specific language governing permissions and limitations
       under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
      package="com.mage.edunxt" android:versionName="1.0" android:versionCode="1" android:hardwareAccelerated="true">
    <supports-screens
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:xlargeScreens="true"
        android:resizeable="true"
        android:anyDensity="true"
        />

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.RECORD_VIDEO"/>
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />   
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />   
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.BROADCAST_STICKY" />

    <application android:icon="@drawable/icon" android:label="@string/app_name"
        android:hardwareAccelerated="true"
        android:debuggable="true">
        <activity android:name="EduNxtQTIPlayer" android:label="@string/app_name"
                android:theme="@android:style/Theme.Black.NoTitleBar"
                android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

    <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/>
</manifest> 

我必須做以下事情

  1. 將所有文件添加到我的res / Drawables文件夾中
  2. 在manifest.xml中設置活動的icon屬性。 它讓我可以選擇瀏覽Drawable目錄中的文件設置。
  3. 我必須做一個干凈的工作。

清潔是非常重要的,它似乎繼續使用舊圖標,直到你清理。

在eclipse項目 - >清潔

我通過這樣做得到了它。

我只是將我的圖標放在"project/bin/res"中的所有文件夾中。

然后我在"project/res/xml"下的config.xml中添加了以下行。

<icon src="icon.png" /> 

現在它很酷。

我一直在使用phonegap CLI在本地構建。 沒有Eclipse並且在查看根文件夾時遇到了多個問題(對本地構建沒用.Phonegap:在構建時如何噴出一些注釋)。

我終於將不同大小的單個圖標文件復制到drawable *文件夾中。

drawable-hdpi drawable-ldpi drawable-mdpi drawable-xhdpi

這浪費了我的時間LOOOOOOOT

在<project location> \\ platforms \\ android \\ ant-build \\ res中進行更改,而不是<project location> \\ platforms \\ android \\ res

對於有些人在后一個位置進行更改可能有效,但是注意到Phonegap從\\ android \\ res復制到\\ android \\ ant-build \\ res,我決定在那里簽到並找到一組包含默認值的可繪制文件夾phonegap圖標。

改變那些最終工作。

由於我在本地構建和運行而不使用Adobe PhoneGap Build,因此更改<project location> \\ www \\ res \\ icon \\ android中的圖標也不起作用。

我還想在這個問題上分享我的答案,以防他們無法使用之前用戶提供的步驟使其工作。

我不能使用這里提供的步驟讓我的工作,我能夠通過使用mipmaps來解決它。 我使用這個非常棒的開源項目生成了圖標大小: Android Asset Studio

我現在注意到生成的圖標現在放在mipmap文件夾中,而不是放在drawables上。 我認為谷歌希望我們將抽象與圖標分開。 完成此操作后,我使用以下方法引用新導入的mipmap文件夾:

 android:icon="@mipmap/ic_launcher"

這是文件夾結構:

res/
    mipmap-mdpi/ic_launcher.png (48x48 pixels)
    mipmap-hdpi/ic_launcher.png (72x72)
    mipmap-xhdpi/ic_launcher.png (96x96)
    mipmap-xxhdpi/ic_launcher.png (144x144)
    mipmap-xxxhdpi/ic_launcher.png (192x192)

我清理並重建了項目,現在我可以看到圖標了! 但是有一個問題。 它被添加到更高版本的android(v4.3,如此處所述鏈接 )。 如果這可以在舊版本的android上運行,那么沒有太多的文檔。

PhoneGap網頁上提供的信息解釋了這一點,但乍一看可能不太清楚(鏈接: http//docs.build.phonegap.com/en_US/configuring_icons_and_splash.md.html#_icons )。

簡單說明:只需將您的圖標復制到應用程序根目錄並將其命名為icon.png。 這就是你所需要的。

在我的情況下,我確定,圖標的大小為96x96px(更大的某種方式不起作用,但可能是我的錯)。 上傳和重建后,應用內容也沒有更新 - 所以我需要重復上傳+重建幾次。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM