Android的 - FEATURE_NO_TITLE不工作 [英] Android - FEATURE_NO_TITLE not working

查看:194
本文介绍了Android的 - FEATURE_NO_TITLE不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过布局来显示我对我们的网页,所以我不需要任何标题栏。我想:

 对话D =新的对话框(本);
d.setContentView(R.layout.about_us);
d.setCanceledOnTouchOutside(真);
d.requestWindowFeature(android.view.Window.FEATURE_NO_TITLE);
d.show();

但是当我点击菜单项,它强制关闭。当我评论上面的code的第三行,它显示了我的标题栏,我不需要布局。
P.S:我的活动扩展ActionBarActivity,这是什么原因?如果是的话,我需要一个替代品。


解决方案

传递一个主题,你的对话框可以删除标题栏为您服务。


  1. 添加以下code在RES /价值/ styles.xml:


 <样式名称=NoTitleDialog父=@安卓Theme.Dialog>
    <项目名称=机器人:windowNoTitle>真< /项目>
< /风格>


<醇开始=2>

  • 通过主题,您的对话框:

  • 对话框D =新的对话框(这一点,R.style.NoTitleDialog);

    I am trying to display my about us page via layout, so I don't need any title bar. I tried:

    Dialog d = new Dialog(this);
    d.setContentView(R.layout.about_us);
    d.setCanceledOnTouchOutside(true);
    d.requestWindowFeature(android.view.Window.FEATURE_NO_TITLE);
    d.show();
    

    but when I click on the menu item, it force closes. when I comment the third line of the code above, it shows my layout with title bar, which I don't need. P.S.: my activity extends ActionBarActivity, is this the reason? If yes then I need an alternative.

    解决方案

    Pass a theme to your dialog can remove the title bar for you.

    1. Add the following code in your res/values/styles.xml:

    <style name="NoTitleDialog" parent="@android:Theme.Dialog">
        <item name="android:windowNoTitle">true</item>
    </style>
    

    1. Pass the theme to your dialog:

    Dialog d = new Dialog(this, R.style.NoTitleDialog);

    这篇关于Android的 - FEATURE_NO_TITLE不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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