How to set a maximum width for a view in an android constraintLayout?

Note that if your view has only one horizontal constraint then you need to add this line app:layout_constraintWidth_default="percent

<SeekBar
   ...
    android:layout_width="0dp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintWidth_default="percent"
    app:layout_constraintWidth_max="200dp" />

I think what you're looking for is matchConstraintMaxWidth attribute.

If you add it to your SeekBar with a value of, say, 200dp, keeping left and right constraints to the parent and a width of 0dp, it will stretch the view's width up to 200dp, but if there is more room it will stay at 200dp.

so your xml should look like this:

<SeekBar
   ...
    android:layout_width="0dp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintWidth_max="200dp" />

you should also be able to set it programmatically with

ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(0, 0);
layoutParams.matchConstraintMaxWidth = ...