1.The first important thing is using Android Studio
2. Add, depending on your build.gradle:
dependencies { compile 'com.melnykov:floatingactionbutton:1.3.0' }
3. Creating a layout
<ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="match_parent" /> <com.melnykov.fab.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right" android:layout_margin="16dp" android:src="@drawable/ic_action_content_new" fab:fab_colorNormal="@color/primary" fab:fab_colorPressed="@color/primary_pressed" fab:fab_colorRipple="@color/ripple" />
4. Add namespace
xmlns:fab="http://schemas.android.com/apk/res-auto"
to the layout file.
- You can also set the button type (regular or mini) using the fab_type xml attribute (this is normal by default):
fab:fab_type="mini"
or
fab.setType(FloatingActionButton.TYPE_MINI);
source share