Already 2 hours I can not understand what I'm doing wrong ...

Here is my ConstraintLayout

 <android.support.constraint.ConstraintLayout android:id="@+id/ll_search_passengers_family_members_header" 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="wrap_content" android:background="@color/Seashell" android:orientation="horizontal" android:paddingBottom="@dimen/large_space" android:paddingTop="@dimen/large_space"> <TextView android:id="@+id/textView3" style="@style/Text_16sp.MidnightBlueTwo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:layout_marginLeft="8dp" android:layout_marginRight="0dp" android:layout_marginStart="8dp" android:layout_marginTop="0dp" android:text="@string/add_passengers_from_family_account" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toLeftOf="@+id/tv_search_passengers_number_indicator" app:layout_constraintTop_toTopOf="parent"/> <TextView android:id="@+id/tv_search_passengers_number_indicator" style="@style/Text_12sp.FloatingLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:layout_marginRight="0dp" android:layout_marginStart="@dimen/space_1dp" android:layout_marginTop="8dp" android:gravity="center" android:padding="@dimen/space_1dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintRight_toLeftOf="@+id/iv_search_passengers_expand_family" app:layout_constraintTop_toTopOf="parent"/> <ImageView android:id="@+id/iv_search_passengers_expand_family" android:layout_width="50dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginBottom="8dp" android:layout_marginRight="8dp" android:layout_marginTop="8dp" android:scaleType="center" android:src="@mipmap/search_open_plus" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"/> 

I want it to be so

enter image description here

As a result, I get this result

enter image description here

The text falls to the left abroad of the screen, the number climbs on the text ... I do not understand why the text simply does not fall on the second line?

Already tried to do the same with LinnearLayout and RelativeLayout and still the problem is that the text does not want to go down to the second line and constantly either climbs to something or goes beyond the screen

What am I doing wrong?

  • Probably the point is wrap_content . I don’t know how to work for Constraint, but for LinearLayout, either match_parent work or weight is set to 0 width. Surely there is an analogue for the cost - ax - YuriySPb
  • @YuriySPb I tried it, it does not work ... I need the Twist number indicator TextView to be right after the TextView, if we set weights for all, I LinnearLayout assume 70 for TextView 10 for indicator and 20 for + I’m like all less so until while the length of the text does not decrease by 2 times (as I work with several languages) and it turns out that first the text and after a kilometer the number costs ... In general, it is also crooked ... I tried to put the text with the number in a separate Layout but also does not work - Aleksey Timoshchenko

1 answer 1

If the goal is to position the plus sign icon pressed to the right corner, and expand the text of the first text field up to the second one, while transferring the text to the next line, if there is too much of it, but pressing the second field to the first one, then you can use another Google word do it something like this:

 <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <com.google.android.flexbox.FlexboxLayout android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" app:flexWrap="nowrap" > <TextView android:id="@+id/first" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/second" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_flexShrink="0" /> </com.google.android.flexbox.FlexboxLayout> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/ic_launcher" /> </LinearLayout> 

It uses either FlexboxLayout , where its FlexboxLayout is set to app:flexWrap="nowrap" , its first child is width and height in content, and the second is app:layout_flexShrink="0" added so that it does not shrink if the first element wants a lot of space.

  • As a result, I managed to do this with the help of the guideLine which in ConstraintLayout , but the one you suggested was interesting did not hear about it. Thank you - Aleksey Timoshchenko