Is there a way to change the logo that appears in the ActionBar
inside an Activity
instead of listing it in the Manifest?
The reason I ask is I have an app for phones where I build a similar type of bar across the top with the launcher icon in the left corner similar to the ActionBar
using an ImageView
.
I also allow the user to change that image to one on their phone or on the internet. I am currently making the app work for tablets and would like to just use the ActionBar
instead but can't figure out how to change the image based on the user. There is no method in the ActionBar
class and I could not find a way to modify the icon or logo from the resources.
Anyone know if this is possible or could suggest something I could try?
To generate ActionBar icons, be sure to use the Asset Studio in Android Studio. To create a new Android icon set, right click on a res/drawable folder and invoke New -> Image Asset.
Android ActionBar is a menu bar that runs across the top of the activity screen in android. Android ActionBar can contain menu items which become visible when the user clicks the “menu” button. In general an ActionBar consists of the following four components: App Icon: App branding logo or icon will be displayed here.
Prior to the introduction in API 14 of the setIcon
and setLogo
methods that Jake mentions, you appear to be able to change the ActionBar logo by grabbing the view of android.R.id.home
and setting a new drawable.
ImageView logo = (ImageView) findViewById(android.R.id.home);
logo.setImageDrawable(drawable);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With