0

Ich dachte, dass ich Constraint Layout gut im Griff habe. Aber dieses Höhenproblem ist seltsam.ConstraintLayout falsche Höheneinstellung

Problem

ConstraintLayout mit @id/boarding nimmt die volle Höhe zwischen @id/progress_layout und @id/take_off_button zu Recht. Aber seine Kinder @id/boarding_counter und @id/runway nehmen nicht die gesamte Höhe des Elternteils. Ich habe die richtigen Attribute für Kinder definiert: width:0dp, app:layout_constraintTop_toTopOf="parent",app:layout_constraintBottom_toBottomOf="parent", immer noch nehmen sie nur teilweise zufällige Höhe.

Bitte helfen

Hier mein Layout-Datei ist, und ich habe auch die Screenshots angehängt: enter image description here

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/colorPrimary" 
    android:transitionName="@string/transition_send_to_clip_verification"> 


    <include layout="@layout/toolbar" /> 

    <android.support.constraint.ConstraintLayout 
     android:id="@+id/layout_content" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toBottomOf="@id/toolbar"> 

     <android.support.constraint.ConstraintLayout 
      android:id="@+id/progress_layout" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      app:layout_constraintBottom_toTopOf="@+id/boarding" 
      app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintRight_toRightOf="parent" 
      app:layout_constraintTop_toTopOf="parent"> 

      <android.support.constraint.ConstraintLayout 
       android:id="@+id/progress1" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:padding="@dimen/padding_left_right" 
       app:layout_constraintBottom_toBottomOf="parent" 
       app:layout_constraintHorizontal_weight="1" 
       app:layout_constraintLeft_toLeftOf="parent" 
       app:layout_constraintRight_toLeftOf="@+id/divider1" 
       app:layout_constraintTop_toTopOf="parent"> 

       <TextView 
        style="@style/text_12_bold_primary" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:drawableTop="@drawable/ic_send" 
        android:gravity="center" 
        android:text="Check In" 
        app:layout_constraintLeft_toLeftOf="parent" 
        app:layout_constraintRight_toRightOf="parent" /> 

      </android.support.constraint.ConstraintLayout> 

      <View 
       android:id="@+id/divider1" 
       android:layout_width="0dp" 
       android:layout_height="1dp" 
       android:background="@color/text_primary" 
       app:layout_constraintBottom_toBottomOf="parent" 
       app:layout_constraintHorizontal_weight="0.5" 
       app:layout_constraintLeft_toRightOf="@id/progress1" 
       app:layout_constraintRight_toLeftOf="@id/progress2" 
       app:layout_constraintTop_toTopOf="parent"></View> 

      <android.support.constraint.ConstraintLayout 
       android:id="@+id/progress2" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:padding="@dimen/padding_left_right" 
       app:layout_constraintBottom_toBottomOf="parent" 
       app:layout_constraintHorizontal_weight="1" 
       app:layout_constraintLeft_toRightOf="@id/divider1" 
       app:layout_constraintRight_toLeftOf="@+id/divider2" 
       app:layout_constraintTop_toTopOf="parent"> 

       <TextView 
        style="@style/text_12_bold_primary" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:drawableTop="@drawable/ic_send" 
        android:gravity="center" 
        android:text="Choose destination" 
        app:layout_constraintLeft_toLeftOf="parent" 
        app:layout_constraintRight_toRightOf="parent" /> 


      </android.support.constraint.ConstraintLayout> 

      <View 
       android:id="@+id/divider2" 
       android:layout_width="0dp" 
       android:layout_height="1dp" 
       android:background="@color/text_primary" 
       app:layout_constraintBottom_toBottomOf="parent" 
       app:layout_constraintHorizontal_weight="0.5" 
       app:layout_constraintLeft_toRightOf="@id/progress2" 
       app:layout_constraintRight_toLeftOf="@id/progress3" 
       app:layout_constraintTop_toTopOf="parent"></View> 

      <android.support.constraint.ConstraintLayout 
       android:id="@+id/progress3" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:padding="@dimen/padding_left_right" 
       app:layout_constraintBottom_toBottomOf="parent" 
       app:layout_constraintHorizontal_weight="1" 
       app:layout_constraintLeft_toRightOf="@id/divider2" 
       app:layout_constraintRight_toRightOf="parent" 
       app:layout_constraintTop_toTopOf="parent"> 

       <TextView 
        style="@style/text_12_bold_primary" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:drawableTop="@drawable/ic_send" 
        android:gravity="center" 
        android:text="Take Off" 
        app:layout_constraintBottom_toBottomOf="parent" 
        app:layout_constraintTop_toTopOf="parent" /> 


      </android.support.constraint.ConstraintLayout> 
     </android.support.constraint.ConstraintLayout> 


     <android.support.constraint.ConstraintLayout 
      android:id="@+id/boarding" 
      android:layout_width="0dp" 
      android:layout_height="0dp" 
      app:layout_constraintBottom_toTopOf="@id/take_off_button" 
      app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintRight_toRightOf="parent" 
      app:layout_constraintTop_toBottomOf="@id/progress_layout"> 

      <android.support.v7.widget.RecyclerView 
       android:id="@+id/boarding_counter" 
       android:layout_width="0dp" 
       android:layout_height="0dp" 
       app:layout_constraintBottom_toBottomOf="parent" 
       app:layout_constraintLeft_toLeftOf="parent" 
       app:layout_constraintHeight_default="spread" 
       app:layout_constraintRight_toLeftOf="@+id/runway" 
       app:layout_constraintTop_toTopOf="parent"></android.support.v7.widget.RecyclerView> 

      <android.support.constraint.ConstraintLayout 
       android:id="@+id/runway" 
       android:layout_width="0dp" 
       android:layout_height="0dp" 
       app:layout_constraintBottom_toBottomOf="parent" 
       app:layout_constraintHeight_default="spread" 
       app:layout_constraintLeft_toRightOf="@id/boarding_counter" 
       app:layout_constraintRight_toRightOf="parent" 
       app:layout_constraintTop_toTopOf="parent"> 

       <ImageView 
        android:layout_width="0dp" 
        android:layout_height="0dp" 
        android:scaleType="centerCrop" 
        app:layout_constraintBottom_toBottomOf="parent" 
        app:layout_constraintLeft_toLeftOf="parent" 
        app:layout_constraintRight_toRightOf="parent" 
        app:layout_constraintTop_toTopOf="parent" 
        app:srcCompat="@drawable/ic_road" /> 

       <android.support.v7.widget.RecyclerView 
        android:id="@+id/taxis" 
        android:layout_width="0dp" 
        android:layout_height="0dp" 
        app:layout_constraintBottom_toBottomOf="parent" 
        app:layout_constraintLeft_toLeftOf="parent" 
        app:layout_constraintRight_toRightOf="parent" 
        app:layout_constraintTop_toTopOf="parent"></android.support.v7.widget.RecyclerView> 

      </android.support.constraint.ConstraintLayout> 

     </android.support.constraint.ConstraintLayout> 


     <android.support.constraint.ConstraintLayout 
      android:id="@+id/take_off_button" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:background="@color/color_primary_bg" 
      android:padding="@dimen/padding_top_bottom" 
      app:layout_constraintBottom_toBottomOf="parent" 
      app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintRight_toRightOf="parent" 
      app:layout_constraintTop_toBottomOf="@id/boarding"> 

      <TextView 
       style="@style/text_16_bold" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:text="TAKE OFF" 
       android:textColor="@color/colorPrimary" 
       app:layout_constraintLeft_toLeftOf="parent" 
       app:layout_constraintRight_toRightOf="parent" /> 
     </android.support.constraint.ConstraintLayout> 

    </android.support.constraint.ConstraintLayout> 
</android.support.constraint.ConstraintLayout> 

aktualisieren

die Bibliothek Version ändern gearbeitet, aber vorübergehend. Wenn ich Artikel in Recycler View @id/taxis hinzufüge, reduziert sich die Höhe wieder auf die Hälfte. Hier

ist das Video:

Gif

+0

Ich habe gerade versucht, dies mit '1.0.2' neu zu erstellen und [das] (https://imgur.com/a/vCwQ5) ist was ich habe. –

+0

Ich komme nicht mit 1.0.2. Also wechselte ich zu 1.1.0-beta3. Jetzt ändert sich die Höhe, wenn ich den Inhalt verändere. Dies ist das erste Mal, dass ich solch ein seltsames Verhalten mit ConstraintLayout erlebt habe. Es wird eine große Hilfe sein, wenn Sie mir die Abhängigkeit einer älteren Version als 1.0.0 geben könnten. Ich habe es gegoogelt, konnte aber keins finden. –

+0

Würde es Ihnen etwas ausmachen, Ihr Projekt zu teilen, damit ich mir das Verhalten ansehen kann? 'ConstraintLayout' soll verschachtelte Views loswerden, also könnte das vereinfachen helfen. Wie für die Version, bin ich mir hier nicht sicher, aber ich denke, es begann mit '1.0.0-alpha1', so dass Sie keine ältere Version finden würden. –

Antwort

1

Update ConstraintLayout 1.1.0-beta3 dieses Problem zu beheben:

Wenn Sie diese später nicht aktualisiert werden kann, wenn auch Beta Version, post zurück für eine alternative Lösung.

+0

Das hat funktioniert. Vielen Dank! Ich habe früher 1.2.0 verwendet. Dies ist ein Fehler in der stabilen und neuesten Version. –

+0

Bitte helfen Sie mit dem Update –

+0

@PrinceBansal Ist dies nicht eine modifizierte XML-Datei? Ich sehe, dass sich die Dinge ein wenig verändert haben. 'runway' war eine Bildansicht, aber jetzt ist ein Einschränkungslayout und' Taxis' sind überhaupt nicht erschienen. – Cheticamp