Normally you can set like below code snippet:
Toolbar chatbox_toolbar = findViewById(R.id.toolbar);
chatbox_toolbar.setTitleTextColor(getResources().getColor(R.color.white));
setSupportActionBar(chatbox_toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.mipmap.ic_back_arrow_gray);
And if you want to add a dunamic image from URL then pls wait i'll update here in a while
Using Glide Library:
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayUseLogoEnabled(true);
Glide.with(this).asDrawable().load(YourImageUrl).into(new CustomTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
getSupportActionBar().setLogo(resource);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
Using Piccasso Library:
final ActionBar MyActionBar = getSupportActionBar();
Picasso.with(this)
.load(YourImageUrl)
.into(new Target()
{
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from)
{
Drawable drawble = new BitmapDrawable(getResources(), bitmap);
MyActionBar .setIcon(drawble);
MyActionBar .setDisplayShowHomeEnabled(true);
MyActionBar .setDisplayHomeAsUpEnabled(true);
}
@Override
public void onBitmapFailed(Drawable errorDrawable)
{
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable)
{
}
});
If not get your result then hide your actionbar home button and take a Imageview in Custom Header Toolbar and then set Image using Glide or piccaso from your Image URL. if you need help into this then let me know further first try above code snippets.
Try out this may helps you