0

2 SpanCount の StaggeredGridLayoutManager で RecyclerView を使用しています。各項目は以下のレイアウトになっています。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/feed_item_margin_bottom"
android:layout_marginTop="@dimen/feed_item_margin_top"
android:background="#ffffff"
android:orientation="vertical" >

    <ImageView
        android:id="@+id/feed_photo"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:src="@drawable/camera" />

    <TextView
        android:id="@+id/feed_caption"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/feed_item_text_margin_left"
        android:layout_marginTop="@dimen/feed_item_text_margin_top"
        android:text="TextView"
        android:textColor="@color/color_primary_dark"
        android:visibility="gone" />

</LinearLayout>

デフォルトでは、TextView (id/feed_caption) は表示されません。項目をクリックすると表示されます。現在、表示によって近くのアイテムがスパンインデックスを変更し、recyclerview のレイアウトが非常に複雑に変更されます。(アニメーションを追加しようとしています)。

私が達成したいのは、すべてのアイテムが独自のスパンインデックスに残ることです。私は検索しましたが、1つのアプローチが見つかりませんでした。何かアドバイスをお願いできますか?ありがとう。

[編集]問題を説明するためにアニメーションを追加してみてください (可能であれば、stackoverflow で直接表示できるようにしてください)

4

1 に答える 1

0

私はうまくいくと思われるアプローチを試しました。ご存知でしたらコメントいただけませんか?危険か何か?

私は、ベースの実装を呼び出さずに onItemUpdated 関数をオーバーライドします。これは、spanindex 設定を無効にするだけです。次のコードを参照してください

 @Override
public void onItemsUpdated(RecyclerView recyclerView, int positionStart, int itemCount) {
    // super.onItemsUpdated(recyclerView, positionStart, itemCount);
}
于 2015-09-06T10:00:41.630 に答える