Skip to content

Commit 689e04f

Browse files
pekingmehunterstich
authored andcommitted
[ProgressIndicator] Added the limit to not have stop indicator size bigger than track thickness.
PiperOrigin-RevId: 599948126 (cherry picked from commit ae11eb4)
1 parent 8167c11 commit 689e04f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/java/com/google/android/material/progressindicator/LinearProgressIndicator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import com.google.android.material.R;
2020

21+
import static java.lang.Math.min;
22+
2123
import android.content.Context;
2224
import android.graphics.drawable.Drawable;
2325
import android.util.AttributeSet;
@@ -179,7 +181,7 @@ public int getTrackStopIndicatorSize() {
179181
*/
180182
public void setTrackStopIndicatorSize(@Px int trackStopIndicatorSize) {
181183
if (spec.trackStopIndicatorSize != trackStopIndicatorSize) {
182-
spec.trackStopIndicatorSize = trackStopIndicatorSize;
184+
spec.trackStopIndicatorSize = min(trackStopIndicatorSize, spec.trackThickness);
183185
spec.validateSpec();
184186
if (getIndeterminateDrawable() != null) {
185187
getIndeterminateDrawable().setInitialTrackStopIndicatorSize(trackStopIndicatorSize);

lib/java/com/google/android/material/progressindicator/LinearProgressIndicatorSpec.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import com.google.android.material.R;
2020

21+
import static java.lang.Math.min;
22+
2123
import android.content.Context;
2224
import android.content.res.TypedArray;
2325
import android.util.AttributeSet;
@@ -91,7 +93,9 @@ public LinearProgressIndicatorSpec(
9193
R.styleable.LinearProgressIndicator_indicatorDirectionLinear,
9294
LinearProgressIndicator.INDICATOR_DIRECTION_LEFT_TO_RIGHT);
9395
trackStopIndicatorSize =
94-
a.getDimensionPixelSize(R.styleable.LinearProgressIndicator_trackStopIndicatorSize, 0);
96+
min(
97+
a.getDimensionPixelSize(R.styleable.LinearProgressIndicator_trackStopIndicatorSize, 0),
98+
trackThickness);
9599
a.recycle();
96100

97101
validateSpec();

0 commit comments

Comments
 (0)