4

How to replace the three dots that appear in the Toolbar by an image.

Is that even possible?

  • Possible [clone](https://stackoverflow.com/q/26300480/3422245) – Alexey Nikitin Jul 17 '17 at 15:45
  • Is it so hard to google before asking? https://www.google.com.ar/search?q=replace+three+dots+in+toolbar – Martin De Simone Jul 17 '17 at 15:46
  • 1
    Possible duplicate of [How to change three dots button on android to other button](https://stackoverflow.com/questions/30267758/how-to-change-three-dots-button-on-android-to-other-button) – an_droid_dev Jul 17 '17 at 15:54
  • I already did read the question twice is not that hard... @an_droid_dev the results give the answer for the action bar not the toolbar. the internet gives the answer for the action bar not the toolbar... Ben P give the good answer. lol – Alfonso Fernandez-Ocampo Jul 17 '17 at 16:23

3 Answers3

14

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)

Ben P.
  • 52,661
  • 6
  • 95
  • 123
1

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>
Mohammed Farhan
  • 1,120
  • 8
  • 14
0

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.

  1. In the menu resource change app:showAsAction="ifRoom" by app:showAsAction="always", that should show the icon whenever possible but it is not recommended.
  2. Use the above configuration to show only the icons you need
  3. Split your actionbar/toolbar so you can show some icons in the top section and some other in the bottom section. You can read more regarding this approach in the following links: here, here and here.

Hope it helps!

Alejandro Casanova
  • 3,633
  • 4
  • 31
  • 46