I think you are looking for matchConstraintMaxWidth .
If you add it to a SeekBar with a value of, say, 200dp , while preserving the left and right restrictions for the parent and the width of 0dp , it will stretch the view width to 200 dp, but if there is more space, it will remain 200 dp.
so your xml looks like this:
<SeekBar ... android:layout_width="0dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintWidth_max="200dp" />
You can also install it programmatically using
ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(0, 0); layoutParams.matchConstraintMaxWidth = ...
source share