I want to hide the top actionbar that I have as an overlay on touch and then show it again on another touch. Somehow I should probably add an onTouchListener to something but how? The event should only be handled when its not consumed by other handlers so that my multitouch will still work when I slide to change image etc. Thanks.
Something like this should work (not tested code - so take with grain of salt)
Basically, override onTouch, and call its super method as to not lose functionality. Check if its consumed, else toggle or whatever to show/hide action bar.
Boolean showBar = true; // Global variable
@Override
public boolean onTouch(View v, MotionEvent event) {
Boolean result = super.onTouch(v,event);
if(!result) // False - Not consumed event.
{
if(showBar) // Toggle action bar visiblity
getActionBar().hide();
else
getActionBar().show();
showBar = !showBar;
}
return result;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With