How do I get a TextView to ripple on long click? It ripples fine onClick
but I need the ripple for onLongClick
.
Asked
Active
Viewed 1,687 times
2

Nouvel Travay
- 6,292
- 13
- 40
- 65
-
In case someone wants more context, my question is a follow up to http://stackoverflow.com/questions/35373987/change-textview-background-with-ripples – Nouvel Travay Feb 13 '16 at 03:30
2 Answers
2
You can use Android Ripple Background
final RippleBackground rippleBackground=(RippleBackground)findViewById(R.id.content);
ImageView imageView=(ImageView)findViewById(R.id.centerImage);
imageView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
rippleBackground.startRippleAnimation();
return false;
}
});

OBX
- 6,044
- 7
- 33
- 77
-
It does not work. Your solution seems to require that the TextView be smaller than the `RippleBackground`. But that won't work for me. I need something that works similar to `android:background="?attr/selectableItemBackground"` – Nouvel Travay Feb 13 '16 at 03:30
-2
There are many ways to implement a longClickListener this is one. Basicly an event is fired examples mouseover, onclick, onlongclick, onlistitemclick and listeners that "hear" the event. post the code if you need more help, did you have new OnLongClickListener() object created?

Community
- 1
- 1

Pomagranite
- 696
- 5
- 11