0

I have btn_hide button in my code.This button appear and disappear by click of a button(btn_main) as below code.

I want to implement to disappear btn_hide when page scrolling and touching any point of the page too.

Please help me.

 btn_hide.setVisibility(rootView.GONE); btn_main.setOnClickListener(new onClickListner(){ @Override public void onClick(View v) { if(btn_hide.getVisibility()==rootView.GONE){ btn_hide.setVisibility(rootView.VISIBLE); }else{ btn_hide.setVisibility(rootView.GONE); } } }); 
3
  • I'm not using FAB and I'm using eclipse Commented May 24, 2016 at 9:07
  • Where is touch event? Commented May 24, 2016 at 9:20
  • @PiyushGupta I dont have a touch event.Help me with a example Commented May 24, 2016 at 10:52

1 Answer 1

0

You need to implement touch event on root view and for detecting scroll on scrollview you need to use below code

scrollView.getViewTreeObserver().addOnScrollChangedListener(new OnScrollChangedListener() { @Override public void onScrollChanged() { int scrollX = rootScrollView.getScrollX(); //for horizontalScrollView int scrollY = rootScrollView.getScrollY(); //for verticalScrollView //DO SOMETHING WITH THE SCROLL COORDINATES } }); 
Sign up to request clarification or add additional context in comments.

2 Comments

Can you please post your error. You can also refer this link for scroll listerner stackoverflow.com/questions/4263053/…
above btn_hide is in horizontal scroll view. I cant remove that. because of above code that scroll view isn't scrolling any more. How to make scroll that horizontal view.( When I scroll the page button disappear This part is working)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.