我能創建使用的主題我的應用程序的簡單閃屏和它工作得很好。但是,有時候應用程序需要刷新大量數據,我想向用戶顯示一個ProgressBar,讓他們知道在等待的過程中發生了什麼。所以我放棄了主題並創建了一個佈局資源,並將其設置爲我的Splash Activity的ContentView,但沒有顯示任何內容。我的內容不僅沒有顯示(完全黑屏),而且標題欄仍然顯示,儘管試圖隱藏每一個可能的方式。
Splash.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:src="@drawable/logo" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp" />
<TextView
android:id="@+id/progressText"
android:text="Loading..."
android:textSize="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp" />
</LinearLayout>
Splash.cs
[Activity(MainLauncher=true, NoHistory = true)]
public class Splash : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
RequestWindowFeature(WindowFeatures.NoTitle);
Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
SetContentView(Resource.Layout.Splash);
string lastUpdated = PreferenceManager.GetDefaultSharedPreferences(this).GetString("LastInventoryUpdate", null);
DateTime lastUpdateDate = Convert.ToDateTime(lastUpdated);
TimeSpan span = DateTime.Today - lastUpdateDate;
if (string.IsNullOrEmpty(lastUpdated) || span.Days > 30)
{
TextView progressText = (TextView)FindViewById(Resource.Id.progressText);
progressText.Text = "Updating parts database. May take several minutes...";
InventoryRepository repository = ((MyApp)Application).Inventory;
repository.Execute();
}
StartActivity(typeof(Login));
}
}
仍顯示在標題欄的標誌和稱號,絕對沒有任何內容。即使嘗試了所有的AsyncTask和StartActivity的東西,只是試圖加載與飛濺佈局的活動。它最終顯示出來,但是它首先顯示爲黑屏。無法想象爲什麼這是我的主要啓動器,並且幾乎沒有任何事情發生,只是設置了活動的內容。
並儘可能標題欄顯示出來,我也嘗試添加這對我的清單
<activity android:name="app.MyApp.Splash" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>
(我目前已經在其他的活動就好了工作),如果我包括該活動的主題TitleBar消失,但我的佈局資源從不顯示。