Tut*_*ain 3 android hide touch android-actionbar
我想隐藏顶部操作栏,我在触摸时将其作为叠加层,然后在另一次触摸时再次显示它.不知怎的,我应该添加一个onTouchListener但是如何?该事件只应在未被其他处理程序使用时进行处理,这样当我滑动更改图像等时,我的多点触控仍然可以工作.谢谢.
像这样的东西应该工作(没有经过测试的代码 - 所以带上一粒盐)
基本上,覆盖onTouch,并调用其超级方法,以免失去功能.检查是否已消耗,否则切换或显示/隐藏操作栏.
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;
}
Run Code Online (Sandbox Code Playgroud)