私はConstraint Layoutをよく把握していると思いました。しかし、この高さの問題は変です。 @id/boarding
とConstraintLayout不適切な高さ調整
問題
ConstraintLayout
は当然@id/progress_layout
と@id/take_off_button
間の完全な高さになります。しかし、その子の@id/boarding_counter
と@id/runway
は、親の全体の高さを取っていません。私は子供に適切な属性を定義しました:width:0dp
、app:layout_constraintTop_toTopOf="parent",app:layout_constraintBottom_toBottomOf="parent"
、それでも部分的なランダムな高さしか取っていません。
ここ
を助けてください、私のレイアウトファイルであると私はまた、スクリーンショットを添付しました:
<?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>
更新
ライブラリのバージョンを変更し、一時的に働いていたけど。 Recycler View @id/taxis
にアイテムを追加すると、再び高さが半減します。ベータ版とはいえ、あなたはこれに更新できない場合は、後で
:
これは '1.0.2'でこれを再現しようとしましたが、[this](https://imgur.com/a/vCwQ5)は私のものです。 –
私は1.0.2と同じようになっています。そこで、1.1.0-beta3に変更しました。私はコンテンツを変更するときに高さが変化しています。 ConstraintLayoutでこのような奇妙な動作を経験したのは初めてのことです。 1.0.0より古いバージョンの依存関係を私に教えてもらえると大きな助けになるでしょう。私はそれをgoogled、しかし1つを見つけることができませんでした。 –
あなたのプロジェクトを共有して、私がその行動を見ることができるでしょうか? 'ConstraintLayout'はネストされたビューを取り除くことになっているので、単純化するといくつかの助けになるかもしれません。 バージョンについては、ここではわかりませんが、それは '1.0.0-alpha1'で始まったと思いますので、古いバージョンは見つかりません。 –