this issue is literally driving me crazy, I've been reading and looking for solutions everywhere and still I am not able to put a custom logo on the Action Bar, I can put background and other features but no logo, I'll put some of the code here, by the way, in the layout designer when i put them "holo light dark action bar" I can see the logo but when I run the app, it never shows up :
Android Manifest:
<application
android:allowBackup="true"
android:icon="@drawable/icon_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Activities.ItemManagerActivity"
android:logo="@drawable/icon_launcher"
android:label="@string/title_activity_item_manager" >
</activity>
<activity
android:name=".Activities.MainActivity"
android:icon="@drawable/icon_launcher"
android:theme="@style/CustomActionBarTheme"
android:label="@string/title_activity_main" >
</activity>
MainActivity:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
android.support.v7.app.AppCompatActivity actionBar;
//getSupportActionBar().setIcon(R.drawable.icon_launcher);
getSupportActionBar().setTitle("");
getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setLogo(R.drawable.icon_launcher);
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:logo">@drawable/icon_launcher</item>
<!-- Customize your theme here. -->
</style>
<style name="CustomActionBarTheme"
parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:logo">@drawable/icon_launcher</item>
<!-- Support library compatibility -->
<!--<item name="background">@drawable/profile_banner_orange</item>-->
</style>
This should do
getSupportActionBar().setIcon(R.drawable.ic_launcher);
But dont forget to add
getSupportActionBar().setDisplayShowHomeEnabled(true);
Along with it