問題描述
我正在嘗試通過布局顯示我的關于我們的頁面,所以我不需要任何標題欄.我試過了:
Dialog d = new Dialog(this);d.setContentView(R.layout.about_us);d.setCanceledOnTouchOutside(true);d.requestWindowFeature(android.view.Window.FEATURE_NO_TITLE);d.show();
但是當我點擊菜單項時,它會強制關閉.當我注釋上面代碼的第三行時,它顯示了我不需要的帶有標題欄的布局.P.S.:我的活動擴展了 ActionBarActivity,是這個原因嗎?如果是,那么我需要一個替代方案.
將主題傳遞給您的對話框可以為您刪除標題欄.
- 在您的 res/values/styles.xml 中添加以下代碼:
<塊引用>
<style name="NoTitleDialog" parent="@android:Theme.Dialog"><item name="android:windowNoTitle">true</item></風格>
- 將主題傳遞給您的對話框:
Dialog d = new Dialog(this, 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.
- Add the following code in your res/values/styles.xml:
<style name="NoTitleDialog" parent="@android:Theme.Dialog"> <item name="android:windowNoTitle">true</item> </style>
- Pass the theme to your dialog:
Dialog d = new Dialog(this, R.style.NoTitleDialog);
這篇關于Android - FEATURE_NO_TITLE 不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!