As we know we can set action
text to the snackbar
.But I wanna make the whole snackbar clickable
.
For that I tried to make the view
of snackbar
clickable but it was futile. Can anyone please help me to solve this?
Code:
Snackbar snackbar=Snackbar.make(home_btn, content, Snackbar.LENGTH_LONG);
View sbView = snackbar.getView();
sbView.setClickable(true);
sbView.setFocusable(true);
sbView.setBackgroundColor(Color.parseColor("#ffffff"));
TextView tv = sbView.findViewById(android.support.design.R.id.snackbar_text);
tv.setTextColor(Color.parseColor("#001919"));
CoordinatorLayout.LayoutParams params=(CoordinatorLayout.LayoutParams)sbView.getLayoutParams();
params.gravity = Gravity.TOP;
sbView.setLayoutParams(params);
snackbar.show();
sbView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent();
i.setAction(action);
i.putExtras(b);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
}
});