【发布时间】:2018-10-03 01:33:18
【问题描述】:
我已经创建了没有任何布局 xml 文件的启动画面,但这是通过将应用程序徽标居中的矢量 drawable 完成的,如下所示:
<item name="android:windowBackground">@drawable/splash_background</item>
但我也想在下一个后续屏幕中显示相同的应用程序徽标。对于等式在我的例子中,让我们说主活动屏幕,我有一个布局 xml,我用约束布局将图标居中。
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 和 Main Activity 之间发生相同的资产徽标交换时,我可以看到徽标的跳跃行为。
感谢您的帮助。下面是整个源代码的github。
https://github.com/nksaroj/InvestApp
你可以在这里看到绿色标志的跳跃问题
【问题讨论】:
标签: android android-layout splash-screen