Android 横向和纵​​向的启动画面

Android splash screen for both landscape and portrait orientation

如何修改我的代码以设置横向和纵向的启动画面。 我设法在纵向模式下工作并且工作正常。我喜欢这两个方向。请修改此代码。 这是我的 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);
    }

  }

这是我的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>

为横屏设置闪屏。按照以下步骤操作。

  1. res 文件夹下创建文件夹 layout-land
  2. 在该文件夹中,复制 splash_screen.xml 文件。
  3. 将 src 资源肖像启动图像更改为横向启动图像

适当的文件将在 运行 时自动加载。 无需更改 java 代码

我认为您的清单文件有问题。请描述您的主要问题。

<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>