Android:碎片顶部奇怪的白色块';s布局
我现在正在练习用RecycleView创建片段 除了一件事之外,一切看起来都很好:屏幕顶部有一个奇怪的方块 我的fragment.xml如下所示:Android:碎片顶部奇怪的白色块';s布局,android,kotlin,android-fragments,android-recyclerview,Android,Kotlin,Android Fragments,Android Recyclerview,我现在正在练习用RecycleView创建片段 除了一件事之外,一切看起来都很好:屏幕顶部有一个奇怪的方块 我的fragment.xml如下所示: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/a
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#CDF6CF"
tools:context=".ui.start_trip.fragment_start_trip">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/create_a_trip_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/top_start_trip"
app:layout_constraintVertical_bias="1.0">
</androidx.recyclerview.widget.RecyclerView>
<Button
android:id="@+id/create_a_trip_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Button"
app:backgroundTint="#ED7F7F"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.884" />
<TextView
android:id="@+id/top_start_trip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/top_start_trip"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="MissingConstraints" />
</androidx.constraintlayout.widget.ConstraintLayout>
有什么办法帮我摆脱这个障碍吗
谢谢,@anonymous 将您的recyclerView设置为
android:layout_above="@id/create_a_trip_button"
我认为使用相对布局来封装所有内容会更好您的片段看起来不错。问题可能在于查看寻呼机的位置。我们可以看到XML吗?您可以使用布局检查器工具来查看是什么视图导致了这个“奇怪的块”。感谢所有上述答案!!!我使用layout inspector发现我的问题来自activity_main.xml中的“android:paddingTop=“?attr/actionBarSize”,现在我解决了我的问题,谢谢你告诉我layout inspector的存在!!!谢谢你的建议!我将修改这些设置。