Android 如何将同一资产/提款权集中在启动屏幕活动和其他活动之间?

Android 如何将同一资产/提款权集中在启动屏幕活动和其他活动之间?,android,android-layout,splash-screen,Android,Android Layout,Splash Screen,我已经创建了没有任何布局xml文件的启动屏幕,但这是由vector drawable完成的,它将应用程序徽标居中,如下所示: <item name="android:windowBackground">@drawable/splash_background</item> <!-- By adding android:layout_marginTop="26dp" to the ImageView kind of works but not sure wh

我已经创建了没有任何布局xml文件的启动屏幕,但这是由vector drawable完成的,它将应用程序徽标居中,如下所示:

 <item name="android:windowBackground">@drawable/splash_background</item>
    <!-- By adding android:layout_marginTop="26dp" to the ImageView kind of works but not sure why the magic number works
     Not sure where to get the same number for some other devices-->

    <ImageView
        android:id="@+id/imageViewLogo"
        android:layout_width="@dimen/splash_icon"
        android:layout_height="@dimen/splash_icon"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/ic_invest_logo" />


</android.support.constraint.ConstraintLayout>
@drawable/splash\u背景
但我也希望在接下来的屏幕上显示相同的应用程序徽标。对于e.q.在我的例子中,让我们说一下主活动屏幕,在这里我有一个布局xml,在这里我用约束布局将图标居中

    <!-- By adding android:layout_marginTop="26dp" to the ImageView kind of works but not sure why the magic number works
     Not sure where to get the same number for some other devices-->

    <ImageView
        android:id="@+id/imageViewLogo"
        android:layout_width="@dimen/splash_icon"
        android:layout_height="@dimen/splash_icon"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/ic_invest_logo" />


</android.support.constraint.ConstraintLayout>
activity_main.xml

    <!-- By adding android:layout_marginTop="26dp" to the ImageView kind of works but not sure why the magic number works
     Not sure where to get the same number for some other devices-->

    <ImageView
        android:id="@+id/imageViewLogo"
        android:layout_width="@dimen/splash_icon"
        android:layout_height="@dimen/splash_icon"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/ic_invest_logo" />


</android.support.constraint.ConstraintLayout>

但我注意到,当Splash和主要活动之间发生相同的资产徽标交换时,我可以看到徽标的跳跃行为

    <!-- By adding android:layout_marginTop="26dp" to the ImageView kind of works but not sure why the magic number works
     Not sure where to get the same number for some other devices-->

    <ImageView
        android:id="@+id/imageViewLogo"
        android:layout_width="@dimen/splash_icon"
        android:layout_height="@dimen/splash_icon"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/ic_invest_logo" />


</android.support.constraint.ConstraintLayout>
谢谢你的帮助。下面是整个源代码的github

    <!-- By adding android:layout_marginTop="26dp" to the ImageView kind of works but not sure why the magic number works
     Not sure where to get the same number for some other devices-->

    <ImageView
        android:id="@+id/imageViewLogo"
        android:layout_width="@dimen/splash_icon"
        android:layout_height="@dimen/splash_icon"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/ic_invest_logo" />


</android.support.constraint.ConstraintLayout>

    <!-- By adding android:layout_marginTop="26dp" to the ImageView kind of works but not sure why the magic number works
     Not sure where to get the same number for some other devices-->

    <ImageView
        android:id="@+id/imageViewLogo"
        android:layout_width="@dimen/splash_icon"
        android:layout_height="@dimen/splash_icon"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/ic_invest_logo" />


</android.support.constraint.ConstraintLayout>
你可以在这里看到绿色标志的跳跃问题

    <!-- By adding android:layout_marginTop="26dp" to the ImageView kind of works but not sure why the magic number works
     Not sure where to get the same number for some other devices-->

    <ImageView
        android:id="@+id/imageViewLogo"
        android:layout_width="@dimen/splash_icon"
        android:layout_height="@dimen/splash_icon"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/ic_invest_logo" />


</android.support.constraint.ConstraintLayout>

    <!-- By adding android:layout_marginTop="26dp" to the ImageView kind of works but not sure why the magic number works
     Not sure where to get the same number for some other devices-->

    <ImageView
        android:id="@+id/imageViewLogo"
        android:layout_width="@dimen/splash_icon"
        android:layout_height="@dimen/splash_icon"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/ic_invest_logo" />


</android.support.constraint.ConstraintLayout>