I would like to change the app:layout_constraintTop_toBottomOf of an element at runtime. I tried to solve it using this question/answers:
Android : How to programmatically set layout_constraintRight_toRightOf "parent"
Unfortunately my element is a RelativeLayout, so it can not be cast to ConstraintLayout, like in this answer with constraintSet
Then I tried to solve it based on this answer with LayoutParams, but RelativeLayout.LayoutParams has no property like toBottomOf.
The layout looks like this:
<RelativeLayout
android:id="@+id/myElement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/otherElement">
<!-- Child elements -->
</RelativeLayout>