How to replace the three dots that appear in the Toolbar by an image.
Is that even possible?
How to replace the three dots that appear in the Toolbar by an image.
Is that even possible?
The "three dots" you see is called the "overflow icon", which is a configurable part of android.support.v7.widget.Toolbar
.
In Java, call:
Drawable d = /* your drawable here */;
toolbar.setOverflowIcon(d);
Documentation here: https://developer.android.com/reference/android/support/v7/widget/Toolbar.html#setOverflowIcon(android.graphics.drawable.Drawable)
I have done that replaced 3 dots with rate app icon for my app. Change item in main_menu.xml like this
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="schemas.android.com/tools"
tools:context=".MainActivity"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/rateapp_bn"
android:title="Rate App"
android:icon="@drawable/ic_stars_black_24dp"
android:orderInCategory="100"
app:showAsAction="always|withText"/>
</menu>
That is not possible. The three dots are appearing because you have more menu items that the ones that fit in your toolbar.
However you can do the following.
app:showAsAction="ifRoom"
by app:showAsAction="always"
, that should show the icon whenever possible but it is not recommended.Hope it helps!