简体   繁体   English

在显示/隐藏时替代ActionBar混蛋

[英]Alternative to ActionBar jerk on show/hide

I am looking to hide the Sherlock action bar on single tap and show it when user does another single tap thus showing/hiding on alternating single tap. 我希望在单击时隐藏Sherlock操作栏,并在用户再次单击时显示它,从而在交替单击时显示/隐藏。

The code for showing and hiding is: 显示和隐藏的代码是:

    @Override
    public boolean onSingleTapConfirmed(MotionEvent e) {
        ActionBar actionBar = getSupportActionBar();
        if (actionBar.isShowing()) {
            actionBar.hide();
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
        } else {
            actionBar.show();
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

        }
        return super.onSingleTapConfirmed(e);
    }

The above code works fine for me but the problem is the jerk seen by the user when the transition od action and notification bars occurs from shown to hidden and vice versa. 上面的代码对我来说很好用,但是问题是用户在从显示到隐藏以及从显示到隐藏的过渡od动作和通知栏发生变化时,都感到很讨厌。

To avoid the jerk, I added the following line in the onCreate method, but it causes the action bar to cover the UI elements when the action bar comes to visible from invisible state. 为避免这种情况,我在onCreate方法中添加了以下行,但是当操作栏从不可见状态变为可见时,它会使操作栏覆盖UI元素。

requestWindowFeature(com.actionbarsherlock.view.Window.FEATURE_ACTION_BAR_OVERLAY);

Is there any way out by which the jerk is also not there and the action bar is not overlayed on the UI elements when it comes from hidden to visible state? 从隐藏状态到可见状态时,是否有什么办法可以避免混蛋出现并且操作栏没有覆盖在UI元素上?

How about achieving the similar behavior with a sliding menu from top? 从顶部滑动菜单如何实现类似的行为? you could set roatation to SlidingDrawer and use it 您可以将旋转设置为SlidingDrawer并使用它

 android:rotation="180" // in SlidingDrawer manifest tag. 

I understand that SlidingDrawer is deprecated in API 17 but you could always have a custom implementation of this. 我了解在API 17中不推荐使用SlidingDrawer,但是您始终可以对此进行自定义实现。 I'm sure this would be a very smooth implementation for you. 我相信这对您来说将是一个非常顺利的实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM