Reputation: 728
How can I modify my this code to set splash screens for both landscape and portrait orientation. I managed to work on portrait mode and it is working fine. i like ti make it for both the orientation. please modify this code. This is my SplashActivity.java.
public class SplashActivity extends Activity {
// Splash screen timer
private static int SPLASH_TIME_OUT = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
new Handler().postDelayed(new Runnable() {
/*
* Showing splash screen with a timer. This will be useful when you
* want to show case your app logo / company
*/
@Override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
Intent i = new Intent(SplashActivity.this, MainActivity.class);
startActivity(i);
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
}
This is my splash_screen.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imgLogo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/screen_portrait"
/>
</RelativeLayout>
Upvotes: 3
Views: 7667
Reputation: 9121
For having splash screen for landscape screen. follow below steps.
layout-land
under res
folder.splash_screen.xml
file. Appropriate file will be loaded at run-time automatically. no need to change in java code
Upvotes: 3
Reputation: 388
i think problem with you manifest file. and please describe your main problem.
<activity
android:name=".SplashActivity"
android:configChanges="keyboard|orientation|screenSize"
android:label="@string/app_name"
android:theme="@style/AppLoginTheme"
android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Upvotes: 0