当前位置: 首页 > 知识库问答 >
问题:

每个RecycerView项显示在一整页中[重复]

澹台胜
2023-03-14

这是我的RecycerView项的XML代码。问题是,每个项目都显示在一整页的应用程序中。请帮我解决这个问题:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/rootlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="8dp"
    android:background="@color/black"
    android:gravity="center">


  <com.makeramen.roundedimageview.RoundedImageView
    android:id="@+id/iv_wall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="centerCrop"
    app:riv_corner_radius="5dp" />

  <View
    android:id="@+id/view_wall"
    android:layout_width="160dp"
    android:layout_height="70dp"
    android:layout_alignParentBottom="true"
    android:background="@drawable/bg_gradient_black_round"
    android:gravity="center_vertical" />

共有1个答案

萧浩漫
2023-03-14

您已经将项目的宽度和高度设置为match_parent,这使得项目比您想要的要大。按如下方式使用smth:

      <RelativeLayout      xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rootlayout"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginLeft="8dp"
android:background="@color/black"
android:gravity="center">


<com.makeramen.roundedimageview.RoundedImageView
    android:id="@+id/iv_wall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="centerCrop"
    app:riv_corner_radius="5dp" />

<View
    android:id="@+id/view_wall"
    android:layout_width="160dp"
    android:layout_height="70dp"
    android:layout_alignParentBottom="true"
    android:background="@drawable/bg_gradient_black_round"
    android:gravity="center_vertical" />
 类似资料:
  • 我有一个RecycerView,它将在设备中安装apk,并与cardview排序,因为标题说我想只在第一个cardview项上显示特定的文本(RecycerView viewholder)

  • 在调试我的应用程序时,我注意到我的RecycerView显示与提供的数据不一致,即。 > 如果我设置了一个闹钟(RecycerView中的TextView设置了日期),然后滚动我的RecycerView,日期显示在错误的位置。例如,如果我在第4项设置了日期,那么由于某种原因,第3项也设置了日期 我已经查看了文档,但不确定如何相应地修补。你能帮我吗? 我的OnBindViewholder:

  • 当我在wordpress页面上显示一些产品时,我想显示一个简短的描述链接到一个相关的pdf(理想情况下使用pdf图标作为链接) 我已经设法通过使用以下代码来显示简短的描述-但是我如何在已经添加到产品中的元数据中添加一些东西(元数据:pdf_link)-它是一个. pdf文件的网址 添加动作(“购物”后加上“购物”后加上“购物”后加上“购物”后加上“购物”后加上“购物”后加上“购物”后加上“购物”后

  • 在我的应用程序中,我想根据用户的需要显示任意数量的每日通知(这是一种医疗提醒)。用户还设置新通知的时间。但我的应用程序目前只显示一个最新通知。你能帮我解决这个问题吗? 我创建新通知的代码(等由用户预先设置): 和我的AlarmReceiver:

  • 我怀疑原因可能是在ViewHolder中连接字符串,根据我所读到的(检查底部的引用),这应该使用带有占位符的资源字符串来完成,例如 应替换为 其中包括。 https://developer.android.com/guide/topics/resources/string-resource#formattingandstyling https://developer.android.com/ref