I have tried several different fixes to get rid of the TitleBar in my app.
I was able to get rid of the very top bar in MainActivity (with time, battery, etc) but the TitleBar would not go away. Here is the code I used to make the top bar go away:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Here is my activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_flat_720x1280"
tools:context="com.andrewvanpeter.upandaway.MainActivity">
<Button
android:id="@+id/settingsButton"
android:layout_width="128dp"
android:layout_height="38dp"
...
</android.support.constraint.ConstraintLayout>
Here is my AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.andrewvanpeter.upandaway">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".GameActivity" />
<activity android:name=".HelpActivity" />
<activity android:name=".SettingsActivity" />
</application>
</manifest>
Add this style in your style folder
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item> <item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
Set this style to your MainActivity
activity class in your AndroidManifest.xml file
android:theme="@style/AppTheme.NoActionBar"