Recycleview只显示一个项目

时间:2018-01-02 08:07:05

标签: android view android-recyclerview

我将高度设置为换行内容,行仍然占据整个页面 我该怎么做才能解决这个问题?

这是行

的xml文件
SELECT SUM( TEST ) 
FROM (

SELECT @N := @N +1 AS rownumber, 1/3 AS TEST
FROM INFORMATION_SCHEMA.COLUMNS, (

SELECT @N :=0
)dummyRowNums
LIMIT 3000
) AS test

更新这是mainActivity类的java代码!

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/background"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/msg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/pink"
        android:text="c'est quel module"
        android:textSize="18sp" />

    <TextView
        android:id="@+id/time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/msg"
        android:layout_marginLeft="40dp"
        android:text="15:12"
        android:textColor="#666"
        android:textSize="13sp" />

     </LinearLayout>

</RelativeLayout>

2 个答案:

答案 0 :(得分:0)

您正在使用水平方向,这是默认设置。并且您使用“match_parent”宽度,因此您只能看到一个项目。

为linearlayout添加垂直方向

   android:orientation="vertical"
<LinearLayout
   android:orientation="vertical"
   android:layout_width="match_parent"
   android:layout_height="wrap_content">

答案 1 :(得分:0)

我认为这是因为您的可绘制文件:

@drawable/background@drawable/pink

请检查它们的高度并相应地进行更改,以便根据您的需要显示行项目。

相关问题