景觀

2012-10-13 50 views
1

MonoDroid的閃屏活動我已經按照從Xamarin這裏的說明:http://docs.xamarin.com/android/tutorials/Creating_a_Splash_Screen景觀

這工作得很好,但沒有提到橫向模式在所有。我可以將我的飛濺圖像旋轉爲縱向尺寸,從而獲得最佳效果,但它仍然不夠理想:飛濺圖像隨着消失和主要活動啓動而旋轉。這是因爲飛濺活動處於縱向模式,主要活動處於橫向模式。

我已經嘗試在splash活動的Activity屬性中添加'screenOrientation = ScreenOrientation.Landscape`,但這會導致不顯示啓動畫面。

根據this的問題,不可能禁用旋轉動畫,所以我真的很想知道如何在橫向模式下顯示這個初始的飛濺活動,或者其他一些獲得相同結果的方法。下面是飛濺活動的代碼,以及有問題的ScreenOrientation參數。

[Activity(
    Label = "The App Name", 
    Icon = "@drawable/icon", 
    MainLauncher = true, 
    Theme = "@style/Theme.Splash", 
    //ScreenOrientation = ScreenOrientation.Landscape, 
    NoHistory = true)] 
public class ActivitySplash : Activity 
{ 
    protected override void OnCreate(Bundle bundle) 
    { 
     base.OnCreate(bundle); 

     // Start our real activity 
     StartActivity(typeof(ActivityMain)); 
    } 
} 

回答

1

嘗試將以下行添加到閃屏活動中。

RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape; 

像這樣:

[Activity(
    Label = "The App Name", 
    Icon = "@drawable/icon", 
    MainLauncher = true, 
    Theme = "@style/Theme.Splash", 
    //ScreenOrientation = ScreenOrientation.Landscape, 
    NoHistory = true)] 
public class ActivitySplash : Activity 
{ 
    protected override void OnCreate(Bundle bundle) 
    { 
     base.OnCreate(bundle); 


     RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape; 


     // Start our real activity 
     StartActivity(typeof(ActivityMain)); 
    } 
} 
+0

感謝發佈,但不幸的是它沒有幫助。它使現在變得更糟糕,飛濺圖像開始在肖像中壓扁,然後旋轉到風景。 – Aranda

+0

我決定在兩個活動之間進行切換時,只使用小型旋轉動畫。如果你顯示不同的圖像,它不是很糟糕。 – Aranda

0

我也有類似的問題上了Nexus 7,如果你使用RequestedOrientation = ScreenOrientation.Landscape;OnCreate方法裏面,因爲它是mentionned,會有幾秒鐘,其中屏幕將以縱向顯示。

我也嘗試將每個設置都放在我的閃屏的.axml中,並且在它的樣式中但沒有任何效果。

的唯一途徑,我能夠讓它的工作是在活動註解

[Activity(Label = "MySplashScreen", Theme = "@style/SplashTheme", NoHistory = true, MainLauncher = true, ScreenOrientation = ScreenOrientation.Landscape)] 
    public class SplashScreenActivity : Activity 
{ 
// your code goes here ... 
} 

這就是我得到了它的工作問題的唯一方法設置屬性ScreenOrientation = ScreenOrientation.Landscape。我認爲你應該使用它並調查爲什麼當你設置這個屬性時不顯示圖像。

+0

你說:「我能夠使其工作的唯一方法是通過在活動註釋中設置屬性」,但是您的意思是哪個屬性?大概是'ScreenOrientation = ScreenOrientation.Landscape',但我已經嘗試過這一點,在我的Galaxy SII和HTC Descire上,我得到了一個黑色屏幕而不是飛濺圖像。 – Aranda

+0

@Aranda好點,我編輯了我的帖子。它確實是ScreenOrientation屬性。如果您獲得黑屏,您的SplashScreen活動可能顯示的時間不足以讓您看到它嗎?我使用計時器來確保啓動屏幕在加載下一個活動之前至少保留2-3次。 – ForceMagic

+0

是的,我想這可能會消失得太快 - 我不強迫它停留一段時間。它看起來不太可能,因爲它被設置爲肖像(或者屬性被刪除),它幾乎立即顯示。 – Aranda

1

您只需在資源中創建一個名爲drawable-land的文件夾即可。然後,將你的Splash.png放在那裏。沒有額外的C#是必需的。

蓋伊

+0

如果這不起作用呢?我嘗試了這一點,但應用程序似乎總是使用閃屏的肖像版本,即使存在「-land」文件夾中的橫向模式 – PaulVrugt

0

我知道這個職位是舊的,但對於那些在此着陸:使用XML佈局在中心的圖像。這是他們如何在Xamarin Splash Screen演示中顯示的:Splash Screen Demo