The title bar continues to be displayed, even with requestWindowFeature or android: theme

My question is exactly like sabe as a custom title bar - does the title bar of the system bar appear for a short time?

But I could not achieve the same results that @Jerry wrote on the best answer. "When I switched to using a theme to talk about the structure, I don’t need a heading, the problem disappeared, and now I see my own heading directly on first boot"

My code is:

manifest:

<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="3" android:versionName="1.0.2"
package="androidhive.dashboard"     xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application android:icon="@drawable/icone" android:label="@string/app_name">
    <activity 
        android:name="com.androidhive.dashboard.SplashScreen"
        android:theme="@android:style/Theme.NoTitleBar"
        android:label="@string/app_name"
        android:windowSoftInputMode="stateHidden|adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

location:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/SplashTheme"
 >

<ImageView
android:id="@+id/splashscreen_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:contentDescription="Splash"
android:scaleType="centerCrop"
android:src="@drawable/splash"
style="@style/SplashTheme" />

</LinearLayout>

Style:

<style name="SplashTheme" parent="@android:Theme.Black">
<item name="android:windowNoTitle">true</item>
<item name="android:background">@drawable/splash</item>
</style>

SplashScreen.java

public class SplashScreen extends Activity implements Runnable{


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setTheme(R.style.SplashTheme);
    setContentView(R.layout.splashscreen_layout);




    Handler h = new Handler();
    h.postDelayed(this, 15000);
}

@Override
public void run() {
    startActivity(new Intent(this, AndroidDashboardDesignActivity.class));
    finish();
}
}

Thanks for the help!

+5
source share
4 answers

Placed:

android:theme="@android:style/Theme.NoTitleBar"

Under the tab of your application, not with your activity

+6

AndroidManifest !

: SplashScreen.java

public class SplashScreen extends Activity{


    private Handler handler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launcher);

        final Runnable runnable = new Runnable() {

            @Override
            public void run() {
                   Intent intent=new Intent(SplashScreen.this, AndroidDashboardDesignActivity.class);
                   startActivity(intent);
                   finish();

            }
        };
        handler = new Handler();
        handler.postDelayed(runnable, 5000);


    }

theme.xml

<style name="SplashTheme" parent="android:Theme">
    <item name="android:windowBackground">@null</item>
    <item name="android:windowNoTitle">true</item>
</style>

<style name="SplashTheme.FullScreen" parent="android:Theme">
    <item name="android:windowBackground">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
</style>

, , . windowBackround null, RootLayout, , Android .

splashscreen_layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/splash"
    android:orientation="vertical" >

</RelativeLayout>

<uses-sdk android:minSdkVersion="8" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
    android:icon="@drawable/icone"
    android:label="@string/app_name" >
    <activity
        android:name="com.androidhive.dashboard.SplashScreen"
        android:label="@string/app_name"
        android:theme="@style/SplashTheme"
        android:windowSoftInputMode="stateHidden|adjustResize" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

android:theme="@style/SplashTheme" android:theme="@style/SplashTheme.FullScreen"

android:theme="@android:style/Theme.NoTitleBar"

+9

AppCompat -.

The following solution worked for me:

Add a new theme style with no action bar in styles.xmland install parent="Theme.AppCompat.NoActionBar".

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">

    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimary</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowBackground">@color/colorPrimary</item>

</style>


Now we implement the same theme style for your screensaver activity in androidManifest.xml

<activity
        android:name=".ActivityName"
        android:theme="@style/SplashTheme"> // apply splash them here 

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>

Here is the result:

enter image description here

+1
source

In your main function use

 getSupportActionBar().hide();
   getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
0
source

All Articles