How to remove Floating Action Button Android Studio Blank Activity Template


Posted on : Fri, 16th Oct 15 12:52 pm GMT

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 MainActivity.java class.

MainActivity.java Language : Java
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        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.support.design.widget.FloatingActionButton 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

Advertisements






FAB icon removed


We are operating with limited resources due to COVID-19 - Stay Safe!


We stands in support of racial equality!

Follow us : Facebook - Twitter