导入android.support.design.widget.FloatingActionButton;

时间:2019-02-21 13:02:45

标签: android

import android.support.design.widget.FloatingActionButton;

give me eror here and here 
 // Setup FAB to open EditorActivity
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(CatalogActivity.this, EditorActivity.class);
                startActivity(intent);
            }
        });
    }

enter image description here

2 个答案:

答案 0 :(得分:1)

在您的 build.gradle

中添加以下内容
implementation 'com.android.support:design:27.1.1'

答案 1 :(得分:0)

在您的build.gradle中添加以下内容

implementation 'com.google.android.material:material:1.2.0'

在代码中添加以下内容

<com.google.android.material.floatingactionbutton.FloatingActionButton

    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"/> 

文档

https://developer.android.com/guide/topics/ui/floating-action-button