eC Droid eC Droid - 1 year ago 102
Android Question

ConstrainLayout not respecting the hierarchy

Screen ShotI have this layout

....................
<CheckBox
android:id="@+id/cb_remember_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textinput2"
android:text="@string/keep_login"
android:textColor="@android:color/holo_red_dark"
android:textSize="18sp"
android:layout_marginTop="14dp"
app:layout_constraintTop_toBottomOf="@+id/textinput2"
app:layout_constraintBottom_toTopOf="@+id/btn_signin_login" />



<Button
android:id="@+id/btn_signin_login"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/cb_remember_login"
android:backgroundTint="@color/colorAccent"
android:minHeight="75dp"
android:text="@string/signin"
android:textColor="@android:color/background_light"
android:textSize="30sp" android:visibility="visible"
android:layout_marginTop="36dp"
app:layout_constraintTop_toBottomOf="@+id/cb_remember_login"
app:layout_constraintBottom_toTopOf="@+id/tv_forgot_login"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>


<include
layout="@layout/view_circle_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="@+id/btn_signin_login"
app:layout_constraintBottom_toBottomOf="btn_signin_login"
app:layout_constraintLeft_toLeftOf="@+id/btn_signin_login"
app:layout_constraintRight_toRightOf="@+id/btn_signin_login" />




<TextView
android:id="@+id/tv_forgot_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btn_signin_login"
android:text="@string/forgot_pass"
android:textAlignment="center"
android:textColor="@android:color/holo_red_dark"
android:textSize="18sp"
android:layout_marginTop="14dp"
app:layout_constraintTop_toBottomOf="@+id/btn_signin_login"
app:layout_constraintBottom_toTopOf="@+id/tv_copyrights_login"
tools:layout_editor_absoluteX="0dp" />

...........][1]][1]


Here is
view_circle_progress.xml


<ProgressBar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:indeterminateTint="@color/red">

</ProgressBar>


You can see my included layout comes after the button but in the picture you can see it's actually beneath the button. Please help with a solution. Also except the included layout all the views are in a chain.

Answer Source

Go to your xml, click design. The on the upper left, corner you will see an icon similar to a blueprint. Click on it and you will get your layout as a blue print. Then click on the element that you want, you will see four points on all sides. Click on the upper point and drag it to the upper bar(menu, etc.). That way you will attach it and it will stay in place. If you want to make offset look on you right above the properties you will see a box representing the item with its constraints, just put the distance you want, and you will have your offset.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download