Android:ActionBar在显示和隐藏时出现故障 [英] Android: ActionBar glitch on show and hide

查看:61
本文介绍了Android:ActionBar在显示和隐藏时出现故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在单击时显示/隐藏操作栏.

I would like to show/hide the action bar upon a click.

它确实可以显示和隐藏,但它并不平滑...底部隐藏了一段时间,但是背景不同,消失了一会儿.

It does show and hide but it is not smooth...the bottom part hides but a different background for a little while before disappearing.

我什至在一个简单的hello world应用程序中尝试过,结果是相同的.这是代码:

I even tried it in a simple hello world app and the result is the same. Here's the code:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TextView tv = (TextView) findViewById(R.id.shit);
        tv.setOnClickListener(new OnClickListener() {


            public void onClick(View v) {
                getActionBar().hide();

            }
        });
    }

推荐答案

使用覆盖模式,而不是显示和隐藏操作栏.

Use overlay mode instead of showing and hiding the actionbar.

操作栏文档:

请注意,隐藏和删除操作栏会导致您的活动重新布局以考虑操作消耗的空间酒吧.如果您的活动定期隐藏并显示操作栏(例如就像在Android Gallery应用中一样),您可能要使用覆盖模式.重叠模式将操作栏绘制在活动布局的顶部而不是在屏幕上自己的区域.这样,您的布局当操作栏隐藏并重新出现时,它保持固定.启用重叠模式,为您的活动创建主题并设置android:windowActionBarOverlay为true.有关更多信息,请参见关于设置操作栏样式的部分.

这篇关于Android:ActionBar在显示和隐藏时出现故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆