show icon in actionbar/toolbar with AppCompat-v7 21
getSupportActionBar().setDisplayShowHomeEnabled(true);
along with
getSupportActionBar().setIcon(R.drawable.ic_launcher);
The application icon does not show on action bar
You are using the AppCompat
version 21+ and it is normal.
The Action Bar follows the material design guidelines and uses a Toolbar.
As you can read here:
The use of application icon plus title as a standard layout is
discouraged on API 21 devices and newer.
If you would like an application icon (but I discourage it), you can use the method setLogo()
.
Something like this:
ActionBar actionBar = getSupportActionBar();
actionBar.setLogo(R.drawable.my_logo);
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
Logo are not displayed in Actionbar, using AppCompat
I removed all the android:logo attributes from my AndroidManifest.xml and I modified my MyActionBarLogo style like this:
<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|showHome</item>
</style>
Now the actionbar is displaying my logo. :)
Drawer Indicator on ActionBar compat v7 21
You got that issue because you set (android:)homeAsUpIndicator
in your theme. Remove that attribute will solve your problem.
Android actionbar icon
Try this code. Import v7.widget.Toolbar and extends AppCompatActivity
import android.support.v7.widget.Toolbar;
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setIcon(R.drawable.ic_statusbar_msg);
Related Topics
Reading a JSON File in Android
Android Remove Space Between Tabs in Tabwidget
Activity Layout: Fragment Class: VS Android:Name Attributes
Android Java.Lang.Noclassdeffounderror
Android SQLite Issue - Table ... Has No Column Named
Gradle Dsl Method Not Found: 'Runproguard'
Android Spanned, Spannedstring, Spannable, Spannablestring and Charsequence
Read & Writing Arrays of Parcelable Objects
Blur Background Behind Alertdialog
Broadcastreceiver + Sms_Received
Android - Save/Restore Fragment State
Date Formatting Based on User Locale on Android
How to Force Action Bar Overflow Icon to Show
Flash Video Not Displaying in Webview for Android 3.0.1
Pass Arraylist from One Activity to Other