2

こんにちは私は使用しようとしていますRecyclerview

以下のコードでは空白の画面しか表示されません。どこが間違っているのか教えてください。

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:gravity="top|center_vertical">

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

    <ImageView
        android:id="@+id/ImageViewSelectPhoto"
        android:layout_width="80dp"
        android:layout_height="76dp"
        android:src="@drawable/ic_add_a_photo_black_361px"
        android:background="@drawable/back"
        android:layout_marginRight="20dp"
        android:layout_marginBottom="20dp" />

</LinearLayout>
4

3 に答える 3

1

Horizo​​ntal-scrollview 用のリスト アイテム レイアウトと、それ用の別のアダプターを作成する必要があります。

追加してみるandroid:viewfillport="true"

私も同様のタイプの質問をしました。それを見てください。これを実装する簡単な方法がきっと得られます。

水平リストビューが github から機能しない

于 2016-02-21T10:32:31.707 に答える
1
  1. ご提供いただきましたので

        android:layout_width="match_parent"
        android:layout_height="match_parent"
    

    RecyclerView の場合、デバイスまたは親ビューの幅と高さ全体を取ります。ImageView はデバイス画面の外にあります。

  2. これで、XML で RecyclerView が宣言されました。RecyclerView アイテムのレイアウトを定義する RecyclerView 行レイアウトが必要です。

RecyclerView に何かを表示するには、Row Layout レイアウト自体に静的データを設定するか、動的/静的データ用の RecyclerView アダプターとモデルを作成する必要があります。

于 2016-02-21T10:18:58.633 に答える