Search code examples
androidxmlfadein

Fade_in effect stopped working after changing theme to NoTitleBar (in manifest)


I am designing a splash screen for my app which I'm working on from last 1 month. i have added an image in an xml file and applied a fade_in effect to it using fade_in.xml .. but one strange thing i noticed is that fade_in works perfectly when using the AppTheme but stops working when i changed the theme to NoTitleBar using the below line of code:

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

(Inside the Manifest.xml)

I need to put this in the manifest...can't remove it ...Any solution will be much appreciated.


Solution

  • Replace it with

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

    OR


    Use the app theme and change the code to

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


    OR use below code for reference


    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.Window;
    import android.view.WindowManager;
    
    public class Splash extends Activity {
    
    	@SuppressWarnings("rawtypes")
    
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		// TODO Auto-generated method stub
    		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    				WindowManager.LayoutParams.FLAG_FULLSCREEN);
    		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.splash);
    		Thread loading = new Thread() {
    			public void run() {
    				try {
    					sleep(1000);
    					startActivity(new Intent(Splash.this, MainActivity.class));
    				}
    				catch (Exception e) {
    					e.printStackTrace();
    				}
    				finally {
    					finish();
    				}
    			}
    		};
    		loading.start();
    	}
    }

    `