Skip to content

Commit

Permalink
[SnackBar] Enforce vertical layout when action text is too long
Browse files Browse the repository at this point in the history
The snack bar content layout is by default horizontal, and we only change it to vertical when the action view is too wide and ellipsizes the message text. Therefore if the layout orientation is already vertical, we should just keep the layout and no need to check if the message text is multi-line again.

Resolves #1876

PiperOrigin-RevId: 419885582
  • Loading branch information
drchen authored and afohrman committed Jan 6, 2022
1 parent a43d7d9 commit ff97a68
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -75,6 +75,12 @@ void updateActionTextColorAlphaIfNeeded(float actionTextColorAlpha) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (getOrientation() == VERTICAL) {
// The layout is by default HORIZONTAL. We only change it to VERTICAL when the action view
// is too wide and ellipsizes the message text. When the condition is met, we should keep the
// layout as VERTICAL.
return;
}

final int multiLineVPadding =
getResources().getDimensionPixelSize(R.dimen.design_snackbar_padding_vertical_2lines);
Expand Down

0 comments on commit ff97a68

Please sign in to comment.