I have made this simple screen. I made like this purposely to show that constraint layout doesn't work properly in case of wrap_content. I know i can make constraint_layout parent and it won't cause the issue but I wanted to understand the reason why this doesn't work.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.konel.kryptapps.testapp.MainActivity">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="text view 1" />
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textView"
tools:text="text view 2" />
</android.support.constraint.ConstraintLayout>
</FrameLayout>
This xml results in the bottom textview being overlapped to the top one. Its constraint of top margin is not being honoured. But if I change the text size of the top textview to 14sp it works perfectly.
Below is the layout bound screen shot:
I have set the text programmatically. First text view contains 100 words from lorem ipsum. I don't understand what I could be doing wrong.
P.S. I am using com.android.support.constraint:constraint-layout:1.0.2