Would it be possible to set the logo and launcher icon dynamically rather than specifying in the manifest
<application
android:icon="#drawable/ic_launcher"
android:logo="#drawable/app_logo"
android:label="#string/app_name"
android:hardwareAccelerated="true">
Call setIcon() and setLogo() on ActionBar to change them at runtime.
EDIT: Works from API level 14 on.
Related
How do I generate Android app launcher icon?
My Manifest file of my android app:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="#style/AppTheme">
I am using Android Studio 3.0.1. In mipmap folder I see many file for ic_launcher. Which file to change for the launcher icon?
Android requires different sizes for same icon so that it can automatically check which size is required for which device.
To add custom launcher icon to your app you have to create a icon with different sizes and add your them in mipmap folder.
Now change the icon name in menifiest file
for example you add a image named my_appicon.png and your roundedIcon name is my_appicon_round.png then in menifiest file
<application
android:allowBackup="true"
android:icon="#mipmap/my_appicon"
android:label="#string/app_name"
android:roundIcon="#mipmap/my_appicon_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
the roundIcon can also be same but if you want to provide round icon for your app you can do this using
roundIcon property.
Note: different image sizes are not compulsary android can auto resize your images to different sizes if you don't provide them.
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:logo="#drawable/logo"
android:theme="#style/AppTheme" >
This is my androidmanifest.xml
and in mainactivity.java i use this lines to show logo in action bar.
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.logo);
after using this two lines in .java file my logo is showing in the display but the app label is gone....
is their any method by which logo & app label both will shown in actionbar after compiling apk.
You not need the two lines in mainactivity.java, you have to select a Theme with the ActionBar:
From res>layout>activity_main.xml(or whatever is the name of the layout of your activity): in the "Design" tab change the theme in "Holo.Light.DarkActionBar" for example.
Or from the AndroidManifest.xml in your app add (or change):
android:theme="#style/AppTheme"
where "AppTheme" is defined in res>values>styles.xml as:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"></style>
Of course in your manifest you have to define the name and logo in the <application> level:
<application
android:logo="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/AppTheme"
...
Add this into your Activity in manifest.
<activity
android:name=".MainActivity"
android:label="#string/app_name"
</activity>
copy your image file and paste it to the res->minmap folder and then goto your AndroidManifest file and locate the below option
android:icon="#mipmap/image_file_name"
give your icon image file name name here (image_file_name) then run your app.
I am building an Android app. In this app I have added a launcher icon (to be used as an app icon) but I also using another icon to be used in the actionbar on all activities. The activity icon got a transparent background color but the application icon is using a solid color background.
The problem is that when I install the app the application is using the activitity icon instead of the launcher icon. The problem with this is that the app icon get a transparent background color instead of a solid one.
What is wrong?
This is my manifest code for the application:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:name="com.example.dev.MyApplication"
android:theme="#style/Theme.Example" >
This is the manifest code for one of the activities (the are all the same):
<activity
android:name=".ui.TasksDetailsActivity"
android:icon="#drawable/ic_menu_logo"
android:screenOrientation="portrait"
android:label="#string/title_activity_tasks_details" >
</activity>
The app is using the ic_menu_logo (transparent) instead of the ic_launcher (solid color) icon when installing the app.
Don't use "android:icon". Use "android:logo" instead:
<activity
android:name=".ui.TasksDetailsActivity"
android:logo="#drawable/ic_menu_logo"
android:screenOrientation="portrait"
android:label="#string/title_activity_tasks_details" >
</activity>
I've developed a navigation drawer for my app, but the toggle button is shown in white. This is my image for the button
And this is how it is shown on my app
Does anyone know why this happends?
You just make sure your app theme If you having your Theme like black you just apply this theme in your Application Mainfest file
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Light" >
......
....
</application>
Afterwards you are getting the same pblm you just make sure in your drawable folder image is like your gray color image or not...
If i have specified my Theme for the application such as so:
<application
android:name="main_application.GlobalObjects"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
Do I then need to specify the Theme again for each activity defined in the manifest file like so:
<activity
android:name="main_application.MainActivity"
android:label="#string/app_name" >
android:theme="#style/AppTheme" >
</activity>
Or do i only need to do this when over riding the applications theme for a single activity?
Do I then need to specify the Theme again for each activity defined in the manifest file like so
No, Once you have defined the Theme for the application and applied it in manifest <application> tag then there is not need of specifying Theme for each Activity again.
But if you want different Themes for each activity then in this case you can define separate themes for each activity.
Do I then need to specify the Theme again for each activity defined in the manifest file like so
No. If you need a specific Theme for a particular Activity then you can set it on the Activity. Otherwise just set it on the <application>
Activity and Application Themes
If you want to use same theme all over the application then setting theme in application tag in manifest is good enough. For example, this part of your code
<application
android:name="main_application.GlobalObjects"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
But if you want to use different theme in different activities then you have to specify the theme like your code
<activity
android:name="main_application.MainActivity"
android:label="#string/app_name"
android:theme="#style/ThemeForThisActivity" />
If you need different theme for each of your activity then YES.
If you need same theme for your application then NO.