iv_buttom_home = (ImageView) findViewById(R.id.iv_buttom_home);
iv_buttom_home
.setOnLongClickListener((OnLongClickListener) new ButtomLongClick());
iv_buttom_home
.setOnTouchListener((OnTouchListener) new ButtomLongClick());
自定义的监听类,继承了长按和触摸事件
class ButtomLongClick implements OnLongClickListener, OnTouchListener {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (v.getId() == R.id.iv_buttom_home && misBottomhide) {
if (event.getAction() == MotionEvent.ACTION_UP) {
Animation anim = AnimationUtils.loadAnimation(
getApplicationContext(), R.anim.push_top_in);
anim.setAnimationListener(BottomActivity.this);
ly_bottom_bar.startAnimation(anim);
misBottomhide = false;
}
}
return false;
}