RecyclerView のアイテム レイアウトを clickable="true" に設定し、一部のタッチ イベントを完全に消費するように見えますMotionEvent.ACTION_DOWN
(その後の ACTION_MOVE と ACTION_UP は機能しています)。
item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/demo_item_container"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"> <-- this what breaks touch event ACTION_DOWN
....
</LinearLayout>
onCreate() で非常に基本的な RecyclerView を設定する:
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
... //Standard recyclerView init stuff
//Please note that this is NOT recyclerView.addOnItemTouchListener()
recyclerView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
Log.d("", "TOUCH --- " + motionEvent.getActionMasked());
//Will never get here ACTION_DOWN when item set to android:clickable="true"
return false;
}
});
RecyclerView のこれは意図された動作またはバグですか? まだプレビュー段階なのでしょうか?
PS。これをドキュメントに従ってクリック可能にして、押された状態に反応し、クリック時に波及効果を持たせたいです。false に設定すると、ACTION_DOWN は正常に動作しますが、押された状態はトリガーされず、selectableBackground は効果がありません。