问题
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.
回答1:
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);
来源:https://stackoverflow.com/questions/28080250/android-feature-no-title-not-working