I have created a few apps in an old version of Eclipse. When doing so, I would enter:
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
within in the manifest file, and this has always changed the app theme with no problem. Recently, I began using the fancy new Java-ADT Eclipse program, and when I enter the above statement into the manifest file the app crashes. What I mean by this is when I plug a device in to test the app (whether it's my Galaxy II, Galaxy 4, or Galaxy Tab 3 10.1) the app installs properly (Eclipse gives no errors and claims everything is successful), but on the device the application loads an empty black screen and then crashes soon after with the message "Unfortunately, (app) has stopped". Am I missing something?
Here are some things to note:
The resulting application IS black with no title or notification bar (before crashing), and when I change the theme phrase to the same thing MINUS, say, "Fullscreen" it correctly displays a black screen with a notification bar but no title bar (before crashing). To me, this indicates that the phrase I'm entering is still correct by today's standards, and perhaps the change/modification that is needed lies elsewhere.
If I start a NEW project and run it, the "Hello World" app displays properly on all my devices, yet if I change the default theme (android:theme="@style/AppTheme") in the manifest file to ANY OTHER THEME, the app crashes ("Unfortunately, app has stopped").
I've tried overriding this by going a different route: I entered a series of phrases in the res-values-styles file (items that manually apply the "NoTitle" and "Fullscreen" attributes), but this only works for my Galaxy 4 and Tab 3 10.1 (my Galaxy II still displays the title). Plus the app is white, not black.
Any advice at this point will be a big help! Thanks
Unfortunately this has broken recently (at least in Intellij). Choosing one of the NoTitle themes will crash the app when you run because the theme needs to be a descendant of AppCompat (at least for lower minimum SDK versions), but it seems there isn't one currently that hides the titlebars.
Here is a working fix for hiding the title bar in both your running app as well as in the layout preview:
1) Set your theme back to 'AppTheme' in the AndroidManifest.xml:
android:theme="@style/AppTheme"
2) Update the theme style in res/values/styles.xml by adding (to name="AppTheme"):
<item name="android:windowNoTitle">true</item>
I believe you can also do this with 'android:windowFullscreen' if you also want to hide the action bar.
The above two steps will work when you run the app (emulator or device) but the layout will still show the titlebar. You can hide that for working on your layout by going to the layout (such as activity_main.xml) and then clicking on the theme (AppTheme) above the preview and changing it to something like Light.NoTitleBar. It's unfortunate that the preview ignores the theme changes in styles.xml, but hopefully that will get fixed.
Update 2015/06/08: This instructions no longer work with Android Studio 1.2.1.1, though there is a simple fix (that should have worked in the first place):
You can now set android:theme in the AndroidManifest.xml:
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
I don't know which of the other changes are still required because I didn't roll them back on my project.
Oddly enough I couldn't find Theme.AppCompat.Black... on my system and also couldn't find Theme.Black.... as the OP requests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With