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보기 @id/taxis
에 항목을 추가하면 높이가 다시 절반으로 줄어 듭니다. 베타이기는하지만,이 업데이트 할 수없는 경우 나중에
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta3'
:
나는 이것을'1.0.2'로 다시 만들려고했지만 [this] (https://imgur.com/a/vCwQ5)는 내가 가진 것이다. –
1.0.2에서도 같은 결과를 얻었습니다. 그래서 1.1.0-beta3으로 바꿨습니다. 이제 콘텐츠를 바꿀 때 높이가 변하고 있습니다. ConstraintLayout으로 이상한 동작을 경험 한 것은 이번이 처음입니다. 1.0.0 이전 버전의 종속성을 제공 할 수 있다면 큰 도움이 될 것입니다. 나는 그것을 봤지만 하나를 찾을 수 없었다. –
문제를 살펴볼 수 있도록 프로젝트를 공유 하시겠습니까? 'ConstraintLayout'은 중첩 된 뷰를 없애기 때문에 단순화하는 것이 도움이 될 것입니다. 버전은 확실하지 않지만 1.0.0-alpha1로 시작 했으므로 이전 버전을 찾을 수 없습니다. –