vous pouvez essayer ceci:
getSupportActionBar().setDisplayUseLogoEnabled(true);
MISE À JOUR autre façon:
<style name="MyActionBarLogo" parent="@style/Widget.AppCompat.Light.ActionBar">
<item name="background">@color/mainColor500</item>
<item name="logo">@drawable/actionbar_logo</item>
<item name="displayOptions">useLogo</item>
</style>
Et dans vos principaux styles:
<item name="actionBarStyle">@style/MyActionBarLogo</item>
MISE À JOUR 2 troisième façon, vous pouvez créer une barre d'outils dans l'activité fichier xml comme ça:
<android.support.v7.widget.Toolbar
android:id="@+id/my_awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
Set logo en utilisant la méthode setLogo()
et définir barre d'outils comme support actionbar comme ça:
Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
setSupportActionBar(toolbar);
vous voulez afficher l'icône avant ou après le titre? –
Peu importe vraiment, je veux juste l'obtenir pour montrer @ BrunoFerreira – Nico