-2

I want the add icon seen everywhere in Google apps.

All the default Google apps like Clock, Calendar, Android Pay, etc have the same ( + ) icon as seen here on the right: Google app add button

I searched through the material design icon package and all the default drawables, and it doesn't seem to be included. It looks much better than the one the icon packs supply (left in the image), and so I would like to have it in my app too. Is Google purposefully keeping this to themselves? I imagine it would be very easy for any graphic designer to replicate.

TL;DR Gimme that icon.

Zeek Aran
  • 523
  • 4
  • 18
  • check this out. http://stackoverflow.com/questions/24459352/how-can-i-add-the-new-floating-action-button-between-two-widgets-layouts – M.Waqas Pervez Jun 14 '16 at 05:02

1 Answers1

0

Try this,

add compile 'com.android.support:design:23.1.1' in your gradle

in your xml layout add

<android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:clickable="true"
        android:src="@drawable/ic_done"
        app:layout_anchor="@id/viewA"
        app:layout_anchorGravity="bottom|right|end"/>

To access or handle event of button

in your activity

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(getApplicationContext(),"FAB button clicked",Toast.LENGTH_LONG).show();
            }
        });
Pramod Waghmare
  • 1,273
  • 13
  • 21
  • Hm, not working. I added the compile bit to my gradle, added the floating button to my XML, and added a click listener to my onCreate exactly as you have it (besides the layout_anchor view). Android Studio doesn't know wh at "ic_done" is and all my view IDs are broken in my main activity by highlighting every single "R" with red. – Zeek Aran Jun 14 '16 at 05:26
  • Have you added compile 'com.android.support:design:23.1.1' in build.gradle – Pramod Waghmare Jun 14 '16 at 05:28
  • Yes, like this: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.1.1' } Yay formatting. – Zeek Aran Jun 14 '16 at 05:35
  • change src from android:src="@drawable/ic_done" to any valid image path . Example : android:src="@mipmap/ic_launcher" – Pramod Waghmare Jun 14 '16 at 05:39
  • Oh. My question's purpose was to find the specific icon file that Google uses, as in the right side of the screenshot. I already had a functioning button, though it was not specifically a FloatingActionButton and I'm glad I now know that exists. – Zeek Aran Jun 14 '16 at 13:31