1

I have a RecyclerView in my app and i set background properties to its relative layout for ripple effect. Ripple shows, but only when i tap and hold, or when i touch and move finger a bit (when it's focused).
On a simple click however, (which opens a new activity) ripple doesn't show.

I looked at this answer which adds a delay of 50ms but it is not ideal. A couple of other such questions do not have satisfactory answers either.
Apps like YouTube and Whatsapp show a ripple and then open the screen. Do they use delay too?

these are the attributes i set to the relative layout for ripple:

android:background="?android:attr/selectableItemBackground"
android:foreground="?android:selectableItemBackground"
android:clickable="true"
android:focusable="true"

this is the onclick method (starts a new activity):

RecyclerView recyclerView = findViewById(R.id.recyler);
recyclerView.addOnItemTouchListener
            (new RecyclerTouchListener(getApplicationContext(), recyclerView, new RecyclerTouchListener.ClickListener() {
                @Override
                public void onClick(View view, int position){                     
                 String selection = menuDataSet[position];
                 Toast.makeText(MainActivity.this, "Selected " + selection, Toast.LENGTH_SHORT).show();
                 openScreenFromMenu(position);
                }

Is there a good way to show ripple on simple clicks too? (without using delay)

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

0 Answers0