Android 将跳过recyclerview上方的视图
我在RecycleView上面有CardView,但当页面加载时,RecycleView位于顶部,CardView被跳过。为什么会发生这种情况 看起来你的帖子大部分都是代码;请添加更多详细信息。看起来你的帖子大部分都是代码;请添加更多详细信息。看起来你的帖子大部分都是代码;请添加更多详细信息。看起来你的帖子大部分都是代码;请添加更多详细信息Android 将跳过recyclerview上方的视图,android,xml,android-layout,android-recyclerview,Android,Xml,Android Layout,Android Recyclerview,我在RecycleView上面有CardView,但当页面加载时,RecycleView位于顶部,CardView被跳过。为什么会发生这种情况 看起来你的帖子大部分都是代码;请添加更多详细信息。看起来你的帖子大部分都是代码;请添加更多详细信息。看起来你的帖子大部分都是代码;请添加更多详细信息。看起来你的帖子大部分都是代码;请添加更多详细信息 您已将id为homeMainLayout的ConstraintLayout设置为“消失”。从中删除属性android:visibility=“gone”,
您已将id为homeMainLayout的ConstraintLayout设置为“消失”。从中删除属性android:visibility=“gone”,卡片视图将按预期显示。将您的recyler视图与卡片视图从上到下对齐为cardview和recyclerview添加权重或将约束布局更改为相对布局,在recyclerview中删除下面的行
app:layout\u constraintStart\u toStartOf=“parent”
应用程序:布局图=“父级
您还可以为您的活动添加java代码吗使用一个约束布局作为父级,然后使用适当的约束定义所有子级布局。另外,对recyclerview高度使用matchConstraint,并将其约束到父视图的底部。recyclerview也在这个ConstraintLayout中,我更改了程序中的可见性。
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView 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">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="@+id/homeProgress"
android:layout_width="100dp"
android:layout_height="100dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:progressTint="@color/colorText"
android:visibility="visible"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/homeMainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorBackground"
android:padding="10dp"
android:visibility="gone">
<androidx.cardview.widget.CardView
android:id="@+id/firstPlace"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/colorCardView"
app:cardCornerRadius="10dp"
android:padding="10dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/firstPlaceName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:textColor="@color/colorText"/>
<TextView
android:id="@+id/firstPlaceCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textColor="@color/colorText"/>
</LinearLayout>
<ImageView
android:id="@+id/firstPlaceImage"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/artistsWithImagesRecycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/firstPlace"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:overScrollMode="never"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager">
</androidx.recyclerview.widget.RecyclerView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>