我有一个启动屏幕,在主屏幕之前显示图像几秒钟Activity
启动,它有一个纵向版本(drawable-hdpi/splash)和一个横向版本(drawable-land-hdpi)。启动画面设置方向onCreate()
.
我的问题:
如果我将平板电脑设置为纵向模式并启动应用程序,则初始屏幕会旋转为横向,但由于某种原因,它会加载纵向可绘制对象(仍旋转为横向)而不是可绘制对象的横向版本,即使我们显然在横向模式下。我猜测 Android 在某个地方发现设备本身仍然处于纵向状态,并将可绘制对象解析为纵向版本。有什么线索如何让它加载正确的绘图吗?
Code:
活动_splash.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black" >
<ImageView
android:id="@+id/splash_imageview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
android:scaleType="fitCenter"
android:src="@drawable/splash" />
</FrameLayout>
SplashActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (DisplayUtils.isTablet(this)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
setContentView(R.layout.activity_splash);
舱单的相关部分
<activity
android:name="com.foo.SplashActivity"
android:configChanges="keyboardHidden|screenSize|orientation"
android:noHistory="true"
android:theme="@style/SplashTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)