If I use the Snackbar with a FloatingActionButton the snacks Works fine because the FAB is inside of a CoordinatorLayout layout, but what I want is to make the Snackbar as a action and not be activated by a FAB, I tried to make the Activity as CoordinatorLayout but stil doesnt't Works!
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
This is how the Snackabr reacts inside of a FAB :
And how reacts outside of FAB :
This is how I do outside of FAB!
Snackbar bar = Snackbar.make(getWindow().getDecorView().getRootView(), "Ative o GPS para usar nossos serviços", Snackbar.LENGTH_INDEFINITE)
.setAction("ok", new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
bar.show();
Could you try to create it with "activity.findViewById(android.R.id.content)"
Snackbar.make(findViewById(android.R.id.content),
"Replace with your own action",Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.