问题
How do I get a TextView to ripple on long click? It ripples fine onClick
but I need the ripple for onLongClick
.
回答1:
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;
}
});
回答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?
来源:https://stackoverflow.com/questions/35374861/ripple-effect-on-textview-long-click