Ripple effect on TextView long click

微笑、不失礼 提交于 2020-01-06 02:53:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!