Snackbar width is matching to full width in mobiles but its not setting match_parent when running in tablet. Kindly help me!Code is below
final Snackbar mSnackbar = Snackbar.make(view, "", Snackbar.LENGTH_LONG);
LayoutInflater inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) mSnackbar.getView();
layout.setPadding(0,0,0,0);
TextView textView = (TextView)
layout.findViewById(android.support.design.R.id.snackbar_text);
textView.setVisibility(View.INVISIBLE);
snackView = inflater.inflate(R.layout.snackbar_layout, null);
layout.addView(snackView, 0);
Use the following code snippet to support full width in tablet landscape mode:
Snackbar snackbar = Snackbar.make(view, "Sample Text", Snackbar.LENGTH_LONG)
.setAction("Sample Text", new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
(snackbar.getView()).getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
snackbar.show();
I think this is the default behavior of snackbar
on tablets.for more information look here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With