How to remove Floating Action Button Android Studio Blank Activity Template

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.
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 drawable -> layout -> activity_main.xml
   < 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" />
Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap