How to remove Floating Action Button Android Studio Blank Activity Template

Posted on : Fri, 16th Oct 15 12:52 pm UTC
100+ votes

If you create an Android App project in Android Studio and you select a Black Activity Template you will get FAB : Floating Action Button incorporated with the Activity, if you do not want it then remove the following code blocks.

1. Remove the following code from onCreate class. Language : Java
FloatingActionButton fab = (FloatingActionButton) findViewById(;
    fab.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();

2. Remove the following code from drawables -> layout -> activity_main.xml

activity_main.xml Language : Java
    < android:id="@+id/fab"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email" />
FAB icon removed


FAB icon removed

Code2care's mission is to share varied knowledge in technical and non-technical areas gathered during day-to-day learnings and development activities so that our visitors can leverage this portal to find solutions to their queries without re-inventing the wheel. Technical posts include Learnings, Tutorials, Video Tutorials, Code Snippets, Tips-n-tricks.

Follow us : Facebook - Twitter - Google +