Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b051ef62 authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Don't add title margins during to Toolbar layout if titles don't fit" into lmp-dev

parents 0c1dc53e 4c9765a6
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -1326,6 +1326,8 @@ public class Toolbar extends ViewGroup {
            final View bottomChild = layoutSubtitle ? mSubtitleTextView : mTitleTextView;
            final LayoutParams toplp = (LayoutParams) topChild.getLayoutParams();
            final LayoutParams bottomlp = (LayoutParams) bottomChild.getLayoutParams();
            final boolean titleHasWidth = layoutTitle && mTitleTextView.getMeasuredWidth() > 0
                    || layoutSubtitle && mSubtitleTextView.getMeasuredWidth() > 0;

            switch (mGravity & Gravity.VERTICAL_GRAVITY_MASK) {
                case Gravity.TOP:
@@ -1353,7 +1355,7 @@ public class Toolbar extends ViewGroup {
                    break;
            }
            if (isRtl) {
                final int rd = mTitleMarginStart - collapsingMargins[1];
                final int rd = (titleHasWidth ? mTitleMarginStart : 0) - collapsingMargins[1];
                right -= Math.max(0, rd);
                collapsingMargins[1] = Math.max(0, -rd);
                int titleRight = right;
@@ -1376,9 +1378,11 @@ public class Toolbar extends ViewGroup {
                    subtitleRight = subtitleRight - mTitleMarginEnd;
                    titleTop = subtitleBottom + lp.bottomMargin;
                }
                if (titleHasWidth) {
                    right = Math.min(titleRight, subtitleRight);
                }
            } else {
                final int ld = mTitleMarginStart - collapsingMargins[0];
                final int ld = (titleHasWidth ? mTitleMarginStart : 0) - collapsingMargins[0];
                left += Math.max(0, ld);
                collapsingMargins[0] = Math.max(0, -ld);
                int titleLeft = left;
@@ -1401,9 +1405,11 @@ public class Toolbar extends ViewGroup {
                    subtitleLeft = subtitleRight + mTitleMarginEnd;
                    titleTop = subtitleBottom + lp.bottomMargin;
                }
                if (titleHasWidth) {
                    left = Math.max(titleLeft, subtitleLeft);
                }
            }
        }

        // Get all remaining children sorted for layout. This is all prepared
        // such that absolute layout direction can be used below.