我想在设置主要活动的最终布局之前显示“启动徽标”或图像。
其实我这样做:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.authors);
mContext = this;
showAuthors();
showAuthors 在哪里运行:
private void showAuthors()
{
setContentView(R.layout.authors);
Thread logoTimer = new Thread() {
public void run() {
try {
sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
}
}
};
logoTimer.start();
try {
logoTimer.join();
setContentView(R.layout.activity_main);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
文件 authors.xml ( R.layout.authors ) 与 activity_main 相同,但很干净,只包含一对带有我的姓名和电子邮件的字符串:
<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"
android:background="@raw/call2"
android:src="@raw/call2"
android:scaleType = "centerCrop"
tools:context=".MainActivity" >
<TextView
android:id="@+id/authorsTV"
android:textColor="#FF6600"
android:textSize="16.5sp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="33dp"
android:text="@string/serviceStatus" />
</RelativeLayout>
问题是:一切正常,但屏幕全是白色的空布局。
我在哪里做错了?谢谢大家如果考虑回复我!