3

このように一度に複数のアイテムビューを表示したい

ここに画像の説明を入力

リサイクラー ビュー 23.2.1 を使用しています

compile 'com.android.support:recyclerview-v7:23.2.1'

マイ リサイクラー ビュー xml

       <android.support.v7.widget.RecyclerView
            android:id="@+id/gallary"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scrollbars="horizontal" />

対応する Java コード

 mRecyclerView = (RecyclerView) findViewById(R.id.gallary);
 mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
 mRecyclerView.setLayoutManager(mLayoutManager);

この構成では、一度に 1 つのアイテムしか取得できません。下の画像のように

ここに画像の説明を入力

画像間のスペースがあるため、リサイクラー ビューの wrap_content が機能していないようです。アイテム間のスペースを削除する方法はありますか。

リサイクラー ビューリンクでwrap_contect に関連するバグが 1 つ見つかりましたが、これは修正されています。これが問題の原因かどうかはわかりません。これを修正するための助けをいただければ幸いです

私の行ビュー:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/facebook" />

        <TextView
            android:id="@+id/titletv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/image"
            android:layout_centerHorizontal="true"
            android:text="Testing"
            android:textSize="@dimen/fourteen_sp" />


        <ProgressBar
            android:id="@+id/mainimgloading"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:layout_centerInParent="true"
            android:layout_gravity="center" />


    </RelativeLayout>

</LinearLayout>
4

1 に答える 1

6

行の親 LinearLayout を幅にmatch_parent使用することはできませんwrap_content。そうしないと、そこに表示されるものが得られます。

垂直のリサイクルビューがある場合はwrap_content、幅ではなく高さに使用します

于 2016-07-06T18:27:33.957 に答える