I am trying to make the Snakbar
to MatchParent
in TAB. What I have done is:
Snackbar snackbar = Snackbar
.make(coordinatorLayout, mMessage, Snackbar.LENGTH_LONG);
View view = snackbar.getView();
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
params.width = CoordinatorLayout.LayoutParams.MATCH_PARENT;
params.gravity = Gravity.CENTER | Gravity.BOTTOM;
view.setLayoutParams(params);
snackbar.show();
It increases the width a little big not to the MatchParent
For anybody still looking for an answer:
Snackbar snackbar = Snackbar
.make(coordinatorLayout, mMessage, Snackbar.LENGTH_LONG);
View view = snackbar.getView();
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams();+
params.gravity = Gravity.FILL_HORIZONTAL | Gravity.BOTTOM;
view.setLayoutParams(params);
snackbar.show();
The 'FILL_HORIZONTAL' did the trick for me.
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.