如何修改此代码以设置横向和纵向的启动屏幕。
我设法在纵向模式下工作,并且工作正常。我喜欢我为这两个方向做的。请修改此代码。
这是我的 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>
用于横向屏幕的启动屏幕。请按照以下步骤操作。
- 创建文件夹
layout-land
under res
folder.
- 在该文件夹中,复制
splash_screen.xml
file.
- 将 src 资源纵向启动图像更改为横向启动图像
适当的文件将在运行时自动加载。无需更改java代码
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)