I have 3 views : A,B,C. (A and B are equal in height) At the beginning B's visibility is gone and C's top constraint is the bottom of A , so C appears below A. After some time I change the visibility of A to gone and B to visible. What happens is that C is dragged to the top because A's visibility is gone. What I want to do is set the top constraint of C to the bottom of B. How can I do this? I need to do it programmatically.
Here is where I am now currently ->
<?xml version="1.0" encoding="utf-8"?>
//A
<LinearLayout
android:onClick="clickedOnRecordLayout"
android:layout_marginTop="@dimen/record_layout_top_margin"
android:id="@+id/record_button_layout"
android:gravity="center"
android:elevation="@dimen/elevation_of_record_button"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="@drawable/red_circle_drawable"
android:layout_width="@dimen/radius_of_record_button"
android:layout_height="@dimen/radius_of_record_button">
<ImageView
android:id="@+id/record_image"
android:src="@drawable/ic_microphone"
android:layout_width="@dimen/record_image_dimen"
android:layout_height="@dimen/record_image_dimen" />
</LinearLayout>
//B - initially its visibility is gone
<LinearLayout
android:onClick="clickedOnStartedRecordingLayout"
android:visibility="gone"
android:layout_marginTop="@dimen/record_layout_top_margin"
android:id="@+id/started_button_layout"
android:gravity="center"
android:elevation="@dimen/elevation_of_record_button"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="@drawable/red_circle_drawable"
android:layout_width="@dimen/radius_of_record_button"
android:layout_height="@dimen/radius_of_record_button">
<ImageView
android:id="@+id/stop_image"
android:src="@drawable/ic_stop_recording"
android:layout_width="@dimen/record_image_dimen"
android:layout_height="@dimen/record_image_dimen" />
</LinearLayout>
//C
<TextView
android:layout_marginTop="@dimen/tap_text_top_margin"
app:layout_constraintTop_toBottomOf="@id/record_button_layout"
android:id="@+id/tap_on_microphone_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="@string/tap_to_start_message"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@id/chronometer"
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />