Android 更改布局宽度和高度后,RecylerView不渲染图像

Android 更改布局宽度和高度后,RecylerView不渲染图像,android,android-layout,Android,Android Layout,我有一个回收站 如果我将高度从match_parent更改为wrap_内容,它将不会显示图像,但在其他情况下会显示图像,这有什么问题 主要活动布局 Recylerview项目布局 终于找到了解决方案,它是ImageView的AdjustViewBounds属性。设置为true后,现在我可以按照我想要的方式调整回收器的高度和宽度 以下是回收商查看项目的修订代码 这也很有帮助。您应该显示项目的适配器和布局OK让我补充一下。RecyclerView是可滚动的视图,因此您不应该将包装内

我有一个回收站


如果我将高度从match_parent更改为wrap_内容,它将不会显示图像,但在其他情况下会显示图像,这有什么问题

主要活动布局


Recylerview项目布局



终于找到了解决方案,它是ImageView的AdjustViewBounds属性。设置为true后,现在我可以按照我想要的方式调整回收器的高度和宽度

以下是回收商查看项目的修订代码



这也很有帮助。

您应该显示项目的适配器和布局OK让我补充一下。RecyclerView是可滚动的视图,因此您不应该将包装内容放在RecyclerView的高度。它将仅在中显示一项screen@HiteshSarsava但如果它是可滚动的,那又有什么区别呢?在
main活动布局中使用垂直方向的线性布局而不是相对位置,并将wrap_内容设置为recerview的高度。
 <android.support.v7.widget.RecyclerView
    android:id="@+id/rcView"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

</android.support.v7.widget.RecyclerView>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<android.support.v7.widget.RecyclerView
    android:id="@+id/rcView"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

</android.support.v7.widget.RecyclerView>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
    android:adjustViewBounds="true"
    android:layout_margin="1dp"
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" /> </RelativeLayout>