mirror of
https://github.com/material-components/material-components-android.git
synced 2026-02-20 08:39:55 +08:00
am c12dbbba: am 5c0f9a9e: am 19603542: am fe2bbcd8: Merge "Simplify tab min/max width measure code" into lmp-mr1-ub-dev
* commit 'c12dbbba49eeb05229e4dc97cfbcb3c686049d87': Simplify tab min/max width measure code GitOrigin-RevId=e25caf67ef5b6743788f31a889e27ed45dd4ce1f PiperOrigin-RevId: 140548968
This commit is contained in:
parent
da424be914
commit
87f4c8ca53
@ -1150,14 +1150,13 @@ public class TabLayout extends HorizontalScrollView {
|
||||
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
if (mTabMaxWidth != 0 && getMeasuredWidth() > mTabMaxWidth) {
|
||||
// Re-measure if we went beyond our maximum size.
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(
|
||||
mTabMaxWidth, MeasureSpec.EXACTLY), heightMeasureSpec);
|
||||
} else if (mTabMinWidth > 0 && getMeasuredHeight() < mTabMinWidth) {
|
||||
// Re-measure if we're below our minimum size.
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(
|
||||
mTabMinWidth, MeasureSpec.EXACTLY), heightMeasureSpec);
|
||||
final int measuredWidth = getMeasuredWidth();
|
||||
if (measuredWidth < mTabMinWidth || measuredWidth > mTabMaxWidth) {
|
||||
// Re-measure if we are outside our min or max width
|
||||
widthMeasureSpec = MeasureSpec.makeMeasureSpec(
|
||||
MathUtils.constrain(measuredWidth, mTabMinWidth, mTabMaxWidth),
|
||||
MeasureSpec.EXACTLY);
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user