Fixed
Status Update
Comments
kr...@gmail.com <kr...@gmail.com> #2
correction to sentence:
"RecyclerView might be doing some invalid assumtions" -> "ConstraintLayout might be doing some invalid assumptions"
"RecyclerView might be doing some invalid assumtions" -> "ConstraintLayout might be doing some invalid assumptions"
ar...@zappos.com <ar...@zappos.com> #3
Doesn't this happen even if you get rid of app:layout_constrainedHeight="true" ?
kr...@gmail.com <kr...@gmail.com> #4
Yes,
After removing app:layout_constrainedHeight="true" it does not happen but it also cause view to not respect and grow beyond constraints and margins. This it not something I want.
After removing app:layout_constrainedHeight="true" it does not happen but it also cause view to not respect and grow beyond constraints and margins. This it not something I want.
b....@gmail.com <b....@gmail.com> #6
The problem still persists in 2.0.0. I checked all available previous versions, it was working perfectly fine until beta 8. In the release candidate from July 29, 2020 and official 2.0.0 from August 21, 2020 the problem came back.
ch...@angi.com <ch...@angi.com> #7
still not fixed
Description
What happens can be seen on attached movie (constraintlayoutmeasureissue.mp4).
It seems that that some views, such as layouts with multiline textviews are incorrectly measured and layouted out when using ConstraintLayout with layout_constrainedHeight=true.
This is much more severe on more complex layout but I'm able to reproduce it on simple layout as :
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="
xmlns:tools="
xmlns:app="
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/halfScreenGuideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<EditText android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="10"
android:background="@color/colorGreyAlpha50"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/halfScreenGuideline"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constrainedHeight="true"
app:layout_constrainedWidth="true"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
You can use this project to reproduce this issue:
Expected behavior: View should wrap to new line when text does not fit half width of screen (as per guideline).
Actual behavior: View starts wrapping to new line only when text is long enough that it would not fit full width of screen.
Details:
RecyclerView might be doing some invalid assumtions during measure cycles. Lets assume that:
- screen has 100px width (and 200px height)
- single line of text is 10px
- textview contains text that that is 90px wide.
- textview can take only up to 50px (either with guideline as above or simply with max_width).
There are two measure calls performed in this case:
1.) 1st measure call is MeasureSpec AT_MOST 100px for width and AT_MOST 200px for height. TextView recons that since it has 100px available, it will take 98px witdh and 10px height (1 line). Since there is no need to wrap it wont wrap to next line.
2.) 2nd measure call is MeasureSpec AT_MOST 50px for width (guideline finally is accounted for) and MeasureSpec AT_MOST 10px for height. (10px seems to be result of previous measure call for textView). In this case, however, textview sees that it can be only 50px wide so it takes given 50px but since height cannot be more than 10px, it will not wrap to next line. As a result, despite there is enough space in constrant layout, textview ends up being singleline with long (faded/scrolled/elipsized) text inside instead of being 2 line text view
Once we put more text inside text view - lets say text becomes 120px wide. Only then textview wraps to next line because during first measure call it will be able to tell parent that it will use 2 lines (20px) instead of one line (10px) and during second measure call, the measurespec will be AT_MOST 20px giving enough space for the second line.
Using "max_width" does not seem to impact first measure call as well.
This might be something related to this