ステート リスト ドローアブルを使用してリサイクラー ビュー アイテムをハイライト表示しようとしていますが、リサイクラー ビュー アイテムがハイライト表示されません。私はすべてのSO投稿を試しましたが、問題を解決するものはありません。
これは私のrecyclerViewです:
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:padding="@dimen/item_offset"
android:focusable="true"
android:clickable="true"
android:scrollbars="none"
android:drawSelectorOnTop="true"
android:listSelector="@drawable/highlight"
android:foreground="@drawable/highlight"
/>
私の単品コード:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foreground="@drawable/highlight"
android:descendantFocusability="blocksDescendants"
android:padding="5dp">
<ImageView
android:id="@+id/grid_item_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:foreground="@drawable/highlight"
android:clickable="true"
android:focusable="true"
android:scaleType="centerCrop">
</ImageView></RelativeLayout>
highlight.xml セレクターのコードは次のとおりです。
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/blue" android:state_pressed="true" />
<item android:drawable="@color/blue" android:state_selected="true" />
<item android:drawable="@color/blue" android:state_focused="true" />
<item android:drawable="@color/white" /></selector>
私はすべての可能な解決策を試しました。誰かがあなたの貴重なアイデアを共有して私を助けてくれませんか?