2017-07-25 24 views
0

的橫向或縱向模式我使用C#在Visual Studio 2017年和Xamarin.Android(不Xamarin.Forms)在我的項目。爲了清楚起見,我使用「跨平臺應用程序(Xamarin)」,而不是使用「類庫(Xamarin.Forms)。我希望它在IO和Android上都能正常工作。我的應用程序看起來像^^風景模式和< ^在肖像模式(請看它喜歡它是在肖像模式)。基本上我想旋轉的第一個,並把它放在上面,並沒有想改變第二個,並把它放在底部的路要走,如果它是在Xamarin.Android

我搜索了一種方法,如何檢查它是在橫向還是縱向模式。我在論壇中找到的一切都建議我使用Xamarin中的函數表格,甚至Xamarin大學本身,但我不能創建一個新的項目,並將每個類都帶入其中,有沒有你知道如何檢查Xamarin.Droid中的橫向或縱向模式嗎?

回答

0

要控制在Android,開放MainActivity.cs的方向和使用屬性裝飾設置方向。

namespace MyRotatingApp.Droid 
{ 
    [Activity (Label = "MyRotatingApp.Droid", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, 
    ScreenOrientation = ScreenOrientation.Landscape)] **//This is what controls orientation** 
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity 
    { 
     protected override void OnCreate (Bundle bundle) 
} 
+0

在點「全球:: Xamarin.Forms.Platform.Android.FormsApplicationActivity」它給出了一個錯誤的形式,並說「的類型或命名空間名稱‘形式沒有命名空間‘Xamarin’’存在。我說,我在我的項目中使用Xamarin.Android(不Xamarin.Forms),也許這可能是問題嗎?它還在ConfigChanges給出錯誤 –

+0

檢查此鏈接https://developer.xamarin.com/guides/android/application_fundamentals/handling_rotation / –

相關問題