![](/style/images/good.png)
![](/style/images/bad.png)
Why can not I see the default icon in the action bar?
source link: https://www.codesd.com/item/why-can-not-i-see-the-default-icon-in-the-action-bar.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Why can not I see the default icon in the action bar?
This question already has an answer here:
- The application icon does not show on action bar 6 answers
I thought I could be able to display the icon on the action bar, but as you can see it's no working, where's the problem? Maybe it depends on the compiledSdkVersion.
My manifest is the default one
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.fulvio.bitsandpizzas">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
My build.gradle:
[![android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.fulvio.bitsandpizzas"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: \['*.jar'\])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
testCompile 'junit:junit:4.12'
}
The icon is not showed in the Toolbar
(the new ActionBar
) by default in the newest versions of Android and if you put it manually it won't follow the material design guidelines:
If you want to put it anyway, you could create a toolbar.xml with your AppBar
and custom Toolbar
and use it in activities including your toolbar layout :
<include layout="@layout/your_layout">
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK