我想为Android应用创建标题屏幕。屏幕是一个简单的XML文件,其中包含图像。基本上屏幕将显示,直到其他一些东西完成加载,屏幕将更改为应用程序内容。问题是,很多时候XML中的图像根本没有出现 - 我得到的只是一个空白的xml页面,然后加载了应用程序。我假设是因为加载图像是异步或其他什么。我试图使用Thread.sleep,这被证明是个坏主意
任何人都知道如何让它工作?
谢谢!
主要的xml:
<RelativeLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginTop="128dp"
android:src="@drawable/icon" />
主要活动:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
<do some stuff>
start_other_activity_with_different_xml();
答案 0 :(得分:0)
好的,找到的答案比我想象的要快。出于我的目的,我正在寻找的是一个闪屏,可以在这里找到如何创建一个的好解释:http://www.androidhive.info/2013/07/how-to-implement-android-splash-screen-2/