Ripple effect on TextView long click

2019-07-28 20:55发布

How do I get a TextView to ripple on long click? It ripples fine onClick but I need the ripple for onLongClick.

2条回答
萌系小妹纸
2楼-- · 2019-07-28 21:13

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;
            }
        });
查看更多
Viruses.
3楼-- · 2019-07-28 21:34

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?

查看更多
登录 后发表回答