How can I change the default logo icon of an ActionBar to be a custom image? Similar as how it works on Whatsapp?
相关问题
- Views base64 encoded blob in HTML with PHP
- How can I create this custom Bottom Navigation on
- How to get the background from multiple images by
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
The simplest technique is to use setIcon(R.drawable.icon_name) Similarly you can do with the Title and you can also set the date in the action bar subtitle.
You need to customize the ActionBarSherlock. Include an xml called "styles_mytheme.xml" in values folder:
Now include this xml in the code:
Now change these three lines, when you change these three lines, the icon will change:
The ActionBar uses the android:logo attribute of your manifest, if one is provided. That lets you use separate drawable resources for the icon (Launcher) and the logo (ActionBar, among other things).
So you should add this tag into manifest like ..
Update :
You can use
ActionBar.setLogo()
for runtime. Two versions are there setLogo(int resId) and setLogo(Drawable logo).Read Define custom Logo for ActionBar (different than Logo) in XML? which will help you to define some styles also.