У меня есть EditText
и RecyclerView
на одном экране.Если пользователь щелкнет значок тега people, RecyclerView
должно появиться в верхней части представления tagPlaceholder
и увеличится до нижней части представления creatorContainer
.Когда видимость RecyclerView установлена на View.GONE
, рядом с кнопкой закрытия должно отображаться представление creatorContainer
.
Макет экрана:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/closeButton"
android:layout_width="@dimen/margin_48"
android:layout_height="@dimen/margin_48"
android:background="@android:color/white"
android:paddingEnd="@dimen/margin_zero"
android:paddingStart="@dimen/margin_small"
android:paddingTop="@dimen/margin_small"
android:src="@drawable/ic_close"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/screenTitle"
android:layout_width="@dimen/margin_zero"
android:layout_height="wrap_content"
android:text="@string/label_create_post"
android:textAppearance="@style/SubtitleAppearance"
android:textColor="@android:color/black"
android:textSize="@dimen/text_large"
app:layout_constraintBottom_toBottomOf="@id/closeButton"
app:layout_constraintEnd_toStartOf="@id/submitPost"
app:layout_constraintStart_toEndOf="@id/closeButton"
app:layout_constraintTop_toTopOf="@id/closeButton"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/submitPost"
android:layout_width="@dimen/margin_48"
android:layout_height="@dimen/margin_huge"
android:layout_marginEnd="@dimen/margin_larger"
android:layout_marginStart="@dimen/margin_larger"
android:text="@string/label_post"
app:layout_constraintBottom_toBottomOf="@id/screenTitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/screenTitle"
style="@style/PrimaryButton"
/>
<androidx.core.widget.NestedScrollView
android:id="@+id/creatorEditorContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/peopleList"
app:layout_constraintTop_toBottomOf="@id/closeButton"
android:layout_marginTop="@dimen/margin_big"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:id="@+id/creatorContainer"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="@dimen/margin_medium"
android:paddingBottom="@dimen/margin_medium"
>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/postCreatorImage"
android:layout_width="@dimen/margin_40"
android:layout_height="@dimen/margin_40"
android:layout_marginStart="@dimen/margin_larger"
android:src="@drawable/ic_man"
tools:src="@drawable/ic_man"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/creatorName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_big"
android:textAppearance="@style/SubtitleAppearance"
android:textColor="@android:color/black"
android:text="Name"
tools:text="Mahesh Nandam"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/creatorDesignation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_big"
android:textColor="@color/colorTextGrey"
android:text="peopleDesignation"
tools:text="Senior Development Engineer"
style="@style/BodyAppearanceRegular"
/>
</LinearLayout>
</LinearLayout>
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/feedInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_15"
android:background="@android:color/white"
android:gravity="top"
android:hint="@string/compose_hint"
android:paddingEnd="@dimen/margin_larger"
android:paddingStart="@dimen/margin_larger"
android:textAppearance="@style/BodyAppearanceRegular"
android:textColor="@color/colorTextGrey"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/creatorContainer"
android:textSize="@dimen/text_medium"
tools:text="Calling all ML and AI enthusiasts."
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<androidx.recyclerview.widget.RecyclerView
android:visibility="gone"
android:id="@+id/peopleList"
android:layout_width="@dimen/margin_zero"
android:layout_height="@dimen/margin_zero"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toTopOf="@id/tagPlaceholder"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/creatorEditorContainer"
tools:itemCount="7"
tools:listitem="@layout/item_people_profile_meta"
app:adapter="@{fragFeedViewModel.getAdapterPeopleListAdapter()}" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/tagPlaceholder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@"
android:gravity="end"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:textAppearance="@style/BodyAppearanceRegular"
android:textSize="@dimen/text_medium"
android:background="@android:color/transparent"
android:paddingTop="@dimen/margin_14"
android:paddingBottom="@dimen/margin_14"
android:paddingStart="@dimen/margin_larger"
android:paddingEnd="@dimen/margin_zero"
/>
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/tagInput"
android:layout_width="@dimen/margin_zero"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="@id/tagPlaceholder"
app:layout_constraintTop_toTopOf="@id/tagPlaceholder"
app:layout_constraintBottom_toBottomOf="@id/tagPlaceholder"
app:layout_constraintEnd_toStartOf="@id/cameraBtn"
android:paddingTop="@dimen/margin_14"
android:paddingBottom="@dimen/margin_14"
android:hint="@string/hint_tag"
android:background="@android:color/white"
android:textAppearance="@style/BodyAppearanceRegular"
android:textSize="@dimen/text_medium"
android:textColor="@android:color/black"
android:layout_marginStart="@dimen/margin_small"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/cameraBtn"
android:layout_width="@dimen/margin_24"
android:layout_height="@dimen/margin_24"
android:paddingStart="@dimen/margin_big"
android:paddingEnd="@dimen/margin_big"
android:paddingTop="@dimen/margin_14"
android:paddingBottom="@dimen/margin_14"
app:layout_constraintStart_toEndOf="@id/tagInput"
app:layout_constraintTop_toTopOf="@id/tagInput"
app:layout_constraintBottom_toBottomOf="@id/tagInput"
app:layout_constraintEnd_toStartOf="@id/galleryBtn"
android:src="@drawable/ic_camera"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/galleryBtn"
android:layout_width="@dimen/margin_24"
android:layout_height="@dimen/margin_24"
app:layout_constraintEnd_toEndOf="parent"
android:paddingStart="@dimen/margin_big"
android:paddingEnd="@dimen/margin_larger"
android:src="@drawable/ic_gallery"
android:paddingTop="@dimen/margin_14"
android:paddingBottom="@dimen/margin_14"
app:layout_constraintStart_toEndOf="@id/cameraBtn"
app:layout_constraintTop_toTopOf="@id/cameraBtn"
app:layout_constraintBottom_toBottomOf="@id/cameraBtn"
app:layout_constraintHorizontal_chainStyle="packed"/>
</androidx.constraintlayout.widget.ConstraintLayout>
На приведенном ниже снимке экрана creatorEditorContainer
вид прилипает к середине экрана.
На изображении ниже видимость RecyclerView исчезла.
Вид creatorEditorContainer
должен быть расположен рядом с видом closeButton
Пожалуйста, помогите мне достичь этого.
Я поместил ограничение creatorEditorContainer
в top_to_bottom из closeButton
и bottom_to_top в RecyclerView
И для свойства layout_height
установлено значение 0dp
, поэтому представление creatorEditorContainer
расположено в середине представления closeButton
, а представление RecyclerView
, помогите мне переместить представление creatorEditorContainer
рядом с представлением closeButton
, не перетаскивая его в центр экрана.