Appcompat 21 logo as back button
After updating sdk to 21 version logo is not displayed. I am displaying a logo using the following code:
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setIcon(R.drawable.ic_launcher);
The code looks like this: http://i.stack.imgur.com/fAWIx.png
This code:
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setIcon(R.drawable.ic_launcher);
Looks at: http://i.stack.imgur.com/hkYqa.png
This code:
actionBar.setDisplayHomeAsUpEnabled(true);
Looks at: http://i.stack.imgur.com/Ssw2A.png
My logo is not showing as a back button.
How do I create an old style like here? http://i.stack.imgur.com/BKOz4.png
Note: Sorry, I didn't see any similar questions. = (
source to share
In the Toolbar Documentation :
- Title and subtitles. The title should be a pointer to the current position of the toolbar in the navigation hierarchy and the content it contains. The subtitle, if present, should indicate any extended information about the current content. If an app uses a logo, it must strongly discard the title and subtitles.
In modern Android interfaces, developers should focus more on a visually distinct color scheme for toolbars than on their app icon. Using the app icon plus title as the default layout is deprecated on API 21 and newer devices.
However, if you want an application icon, setLogo () is indeed the correct method.
source to share
Here is what worked for me using the icon
actionBar.setIcon(R.drawable.ic_app_icon);
actionBar.setDisplayShowHomeEnabled(true);
Or if you need a wider logo
actionBar.setLogo(R.drawable.ic_app_logo);
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayUseLogoEnabled(true);
source to share