本文介绍了横向和纵向的 Android 启动画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何修改我的此代码以设置横向和纵向的启动画面.我设法在纵向模式下工作,并且工作正常.我喜欢在这两个方向上都做到这一点.请修改此代码.这是我的 SplashActivity.java.
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);
}
}
这是我的 splash_screen.xml.
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>
推荐答案
用于横向屏幕的闪屏.请按照以下步骤操作.
For having splash screen for landscape screen. follow below steps.
- 在
res
文件夹下创建文件夹layout-land
. - 在该文件夹中,复制
splash_screen.xml
文件. - 将 src 资源纵向启动图像更改为横向启动图像
- Create folder
layout-land
underres
folder. - In that folder, copy
splash_screen.xml
file. - Change src resource portrait splash image to your landscape splash image
适当的文件将在运行时自动加载.无需更改java代码
Appropriate file will be loaded at run-time automatically. no need to change in java code
这篇关于横向和纵向的 Android 启动画面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!