implementation 'com.google.android.material:material:1.0.0-alpha3'
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_activity_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"
android:layout_marginBottom="30dp" />
</RelativeLayout>
FloatingActionButton fab_activity_main = findViewById(R.id.fab_activity_main);
fab_activity_main.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Toast.makeText(MainActivity.this,"删除成功",Toast.LENGTH_SHORT).show();
Snackbar.make(view,"删除数据",Snackbar.LENGTH_SHORT).setAction("确定", new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this,"删除成功",Toast.LENGTH_SHORT).show();
}
}).show();
}
});