Skip to content

Commit ff97a68

Browse files
drchenafohrman
authored andcommitted
[SnackBar] Enforce vertical layout when action text is too long
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
1 parent a43d7d9 commit ff97a68

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/java/com/google/android/material/snackbar/SnackbarContentLayout.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ void updateActionTextColorAlphaIfNeeded(float actionTextColorAlpha) {
7575
@Override
7676
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
7777
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
78+
if (getOrientation() == VERTICAL) {
79+
// The layout is by default HORIZONTAL. We only change it to VERTICAL when the action view
80+
// is too wide and ellipsizes the message text. When the condition is met, we should keep the
81+
// layout as VERTICAL.
82+
return;
83+
}
7884

7985
final int multiLineVPadding =
8086
getResources().getDimensionPixelSize(R.dimen.design_snackbar_padding_vertical_2lines);

0 commit comments

Comments
 (0)