【发布时间】:2016-06-17 11:57:06
【问题描述】:
亲爱的,
我有一个正方形的 title.png,我以纵向模式(更不用说横向模式)在屏幕上端的(也是正方形的)TitleFragment 中显示它。现在我想在加载时向我的应用程序添加启动画面。我关注了这个tutorial,它工作正常。我的splash.xml 看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/dark"/>
<item>
<bitmap
android:gravity="top"
android:src="@drawable/title"/>
</item>
</layer-list>
如您所见,我使用与 TitleFragment 中相同的 title.png,但是,我未能将其定位在 与 TitleFragment 显示图像相同的位置。我的titlefragment.xml 看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/title"
tools:ignore="ContentDescription"/>
</FrameLayout>
mainactivity.xml 将其定位在屏幕顶部尽可能大的方格中。
我的问题是:我可以在启动画面中模拟片段的定位吗?我希望启动画面中的title.png 和titleFragment 中的title.png 一致。我已经玩过splash.xml (android:gravity="top") 中的相关线路,但无济于事。
编辑:以下是一些屏幕截图。首先是显示启动画面:
第二个是显示主要活动(显然是虚拟文本):
【问题讨论】:
-
你能附上两个屏幕的图像吗?它在您的手机或模拟器中的显示效果如何?
标签: android xml android-layout splash-screen android-bitmap