Reputation: 55
I have a big problem in making simple recycler view. Here is the things.
I have many lines in textview3 & textview4.
It has over 5 lines but it is shown only 3 or 4 lines. even if i've already set maxLines=5
this is my code
RecyclerView's item
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/tv3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
app:layout_constraintWidth_default="spread"
app:layout_constrainedHeight="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@+id/tv4"
app:layout_constraintEnd_toStartOf="@+id/status_layout"
android:maxLines="5"
android:textSize="20dp"
android:text="TextView 3-1 TextView 3-2 TextView 3-3 TextView 3-4 TextView 3-5 TextView 3-6 TextView 3-7 TextView 3-8 TextView 3-9 TextView 3-10"/>
<TextView
android:id="@+id/tv4"
app:layout_constraintEnd_toStartOf="@+id/status_layout"
android:layout_below="@id/tv3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="5"
app:layout_constrainedHeight="true"
app:layout_constraintTop_toBottomOf="@id/tv3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:textSize="20dp"
android:text="TextView 4-1 TextView 4-2 TextView 4-3 TextView 4-4 TextView 4-5 TextView 4-6 TextView 4-7 TextView 4-8 TextView 4-9 TextView 4-10"/>
<LinearLayout
android:id="@+id/status_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentEnd="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:background="#ff00ff">
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:text="TextView 1"/>
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:text="TextView 2"/>
</LinearLayout>
And if i changed maxLines=5 to maxLines=4 then I can see the ellipsize.
In list, I can't see TextView 3-10 and TextView 4-10 Why only 3 lines is shown? I set maxLines to 5. textView3 and textview4 can be from 1 line to 5 line So i want to set maxLines=5, instead lines=5
Can I do like this? right side textview (textview 1,2) have to be located center_vertical on list view item's height. And left side textview (textview 3,4) have to located toStartOf textview 1, 2 and need to ellipsize if it is over maxLines (e.g. 5 lines)
Upvotes: 0
Views: 367
Reputation: 1146
Why are you using app:layout_constrainedHeight="true"
? From the official documentation -
If a dimension is set to WRAP_CONTENT, in versions before 1.1 they will be treated as a literal dimension -- meaning, constraints will not limit the resulting dimension. While in general this is enough (and faster), in some situations, you might want to use WRAP_CONTENT, yet keep enforcing constraints to limit the resulting dimension. In that case, you can add one of the corresponding attribute:
app:layout_constrainedWidth=”true|false” app:layout_constrainedHeight=”true|false”
Meaning use this only when you want to use wrap_content
but also want to enforce some restrictions to height.
Remove this line or set it false.
Upvotes: 1