gpt4 book ai didi

android - ConstraintLayout 中的 RecyclerView 与其他元素重叠

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:51:50 25 4
gpt4 key购买 nike

我正在使用以下组件执行一个简单的列表 Activity :一个 EditText、一个 RecyclerView、一个 ProgressBar 和一个 Textview。一切都很好,除了 RecyclerView 与 EditText 重叠并“超出”屏幕底部,因此最后一项被部分切掉(参见屏幕截图)。我做错了什么?

主要 Activity :

<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="jacopo.com.flickrgallery.GalleryActivity">

<EditText
android:id="@+id/search_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:hint="search by tag..."
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<ProgressBar
android:id="@+id/gallery_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/search_text" />

<android.support.v7.widget.RecyclerView
android:id="@+id/gallery_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/search_text" />

<TextView
android:id="@+id/gallery_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/search_text"
tools:text="error" />

</android.support.constraint.ConstraintLayout>

recyclerview overlapping editext recyclerView going outside the screen

最佳答案

您正在为 RecyclerView 使用 android:layout_height="wrap_content"但看起来你需要限制高度。试试 android:layout_height="0dp"。在这种情况下,它等于 app:layout_constraintTop_toBottomOf="@+id/search_text"app:layout_constraintBottom_toBottomOf="parent"

关于android - ConstraintLayout 中的 RecyclerView 与其他元素重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47455203/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com