Remove Title Bar Phonegap

2019-04-09 00:20发布

问题:

How to remove the title bar that is showing for a second or so at the start of the application in phonegap build? I tried fullscreen as showed in Phonegap remove title bar at start and its working, the app is full screen but the title bar stil shows up for a second or so at the start of the app. When buildin locally I can remove the title bar form manifest.xml with the command android:theme="@android:style/Theme.NoTitleBar">

How can I completely remove the title bar from phonegap build?

I solved it by adding these lines to the config.xml

<gap:config-file platform="android" parent="/manifest">

       <supports-screens 
              android:xlargeScreens="false" 
              android:largeScreens="false" 
              android:smallScreens="false" />
        <application android:theme="@android:style/Theme.NoTitleBar" >
            <activity android:theme="@android:style/Theme.NoTitleBar.Fullscreen" ></activity>
        </application>
</gap:config-file>

回答1:

Alex already provided the solution in the first post. I'd just like to clarify two things:

  1. You don't have to disable support for certain screen sizes for this to work. Note that I've changed the attributes of supports-screens back to true
  2. You need to also provide an android namespace, or PhoneGap Build will complain about a "malformed config.xml" (see the line in bold below)

So this would be your config.xml:

<widget xmlns = "http://www.w3.org/ns/widgets" 
    xmlns:gap = "http://phonegap.com/ns/1.0"

xmlns:android = "http://schemas.android.com/apk/res/android"

    id        = "com.domain.app"
    version   = "1.0.0">

    ...

    <gap:config-file platform="android" parent="/manifest">
        <supports-screens 
            android:xlargeScreens="true" 
            android:largeScreens="true" 
            android:smallScreens="true" />
        <application android:theme="@android:style/Theme.NoTitleBar" >
            <activity android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            </activity>
        </application>
    </gap:config-file>
</widget>

Hat tip to wildabeast on github.



回答2:

I used robro's code and it worked, but everything on my screen was cut off at the top since I allow the status bar using this setting in my config:

<preference name="fullscreen" value="false" />

I then took out the following:

<activity android:theme="@android:style/Theme.NoTitleBar.Fullscreen" ></activity>

and all looks perfect now.



回答3:

Try adding splashscreens (if you don't have them already) I tried it and you can no longer see the title bar.

Your config.xml needs these for Android:

<icon src="icons/android/ldpi.png" gap:platform="android" gap:density="ldpi" />
<icon src="icons/android/mdpi.png" gap:platform="android" gap:density="mdpi" />
<icon src="icons/android/hdpi.png" gap:platform="android" gap:density="hdpi" />
<icon src="icons/android/xhdpi.png" gap:platform="android" gap:density="xhdpi" />

and then add your images to the src.