【发布时间】:2018-09-02 07:33:31
【问题描述】:
首先,这是style/splash_screen.xml
<layer-list xmlns:android="htt..."
android:opacity="opaque">
<item
android:drawable="@color/colorSplash"/>
<item
android:width="100dp"
android:height="100dp"
android:gravity="center">
<bitmap
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="fill"
android:src="@drawable/logo_512" />
</item>
</layer-list>
下面的代码是layout/activity_splash.xml的一部分
<android.support.constraint.ConstraintLayout
xmlns:android="http...
tools:context="com.example.SplashActivity">
<ImageView
android:id="@+id/splash_logo"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/logo_512"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
我将徽标图像放在每个屏幕的中心
还有AndroidManifest.xml,
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme">
当从启动器单击应用程序时,我让我的应用程序显示带有初始加载图像的初始屏幕。
但问题是,样式文件和布局文件的标志位置不同。
当我从 GalaxyS8 启动应用程序时,
初始加载屏幕的徽标图像低于启动屏幕,低至 statusbar_height。
但是当我从我的 AVD 启动应用程序时,
初始加载屏幕的徽标图像高于启动屏幕之一,高于 statusbar_height。
resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
statusbar_height = getResources().getDimensionPixelSize(resourceId);
我还是不明白,为什么在相同的代码、不同的设备上会出现这种差异。
我该如何解决这个问题?
PS:因为我需要在启动画面中添加动画,所以我需要让启动图像和启动画面都必须具有相同的徽标位置。
【问题讨论】:
标签: android center splash-screen