I have two TextViews in a vertical LinearLayout, one serves as a display for a book's title and the latter as a display for the book's author(s). I need the first to have wrap_content as its height, so it takes a good part of the linear layout. However, I want it to cap out at three lines max, so that there is still some space left for the second text view; and I need the latter to fill the remaining space (0dp and layout_weight=0dp). I want to use specific configuration so that the author view will be always right after the title view (on its bottom).
Something like this, however the max_lines do not kick in.
I tried to set max_lines to 3 and wrap_content for the first view height, but it seem that max_lines is ignored if height is set to wrap_content.
I also tried to circumvent the problem by sort of cheating and adding a max_height, but then the two views may be spaced apart from one another.
At last I tried to convert the linear layout to a constraint layout, to see if I could access some other layout settings to no avail.
Any help?
CodePudding user response:
Replacing app:max_lines with android:max_lines seems to have fixed the issue.
CodePudding user response:
It seems to be working fine on my side with android:max_lines="3"
even with wrap_content
This is just a test layout I created
<TextView
android:id="@ id/textview1"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:maxLines="3"
android:textSize="@dimen/_13sdp"
android:textStyle="bold"
android:text="Very Very Very Very Very Very Very Very Very Very Very Very Long Text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@ id/textview2"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Very Very Short Text "
app:layout_constraintStart_toStartOf="@ id/textview1"
app:layout_constraintTop_toBottomOf="@ id/textview1" />
Screenshot ->
Hope this helps! :)