Skip to content

Commit

Permalink
[ProgressIndicator] Added the limit to not have stop indicator size b…
Browse files Browse the repository at this point in the history
…igger than track thickness.

PiperOrigin-RevId: 599948126
(cherry picked from commit ae11eb4)
  • Loading branch information
pekingme authored and hunterstich committed Mar 21, 2024
1 parent 8167c11 commit 689e04f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import com.google.android.material.R;

import static java.lang.Math.min;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
Expand Down Expand Up @@ -179,7 +181,7 @@ public int getTrackStopIndicatorSize() {
*/
public void setTrackStopIndicatorSize(@Px int trackStopIndicatorSize) {
if (spec.trackStopIndicatorSize != trackStopIndicatorSize) {
spec.trackStopIndicatorSize = trackStopIndicatorSize;
spec.trackStopIndicatorSize = min(trackStopIndicatorSize, spec.trackThickness);
spec.validateSpec();
if (getIndeterminateDrawable() != null) {
getIndeterminateDrawable().setInitialTrackStopIndicatorSize(trackStopIndicatorSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import com.google.android.material.R;

import static java.lang.Math.min;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
Expand Down Expand Up @@ -91,7 +93,9 @@ public LinearProgressIndicatorSpec(
R.styleable.LinearProgressIndicator_indicatorDirectionLinear,
LinearProgressIndicator.INDICATOR_DIRECTION_LEFT_TO_RIGHT);
trackStopIndicatorSize =
a.getDimensionPixelSize(R.styleable.LinearProgressIndicator_trackStopIndicatorSize, 0);
min(
a.getDimensionPixelSize(R.styleable.LinearProgressIndicator_trackStopIndicatorSize, 0),
trackThickness);
a.recycle();

validateSpec();
Expand Down

0 comments on commit 689e04f

Please sign in to comment.