2016-06-24 16 views
0

我在Xamarin.Forms工作應用程序,我在那裏用FormsApplicationActivity作爲我的主要活動,並能夠與自定義視圖定製動作條裏面(我把微調在裏面,對於一些頁)FormsAppCompatActivity和自定義動作條/工具欄

但因爲有幾個UI /外觀和感覺的問題我已經升級到FormsAppCompatActivity。 因爲我這樣做,我只是不能讓我的微調工具欄/操作欄!無論我嘗試什麼!

這基本上是以前的代碼,用FormsApplicationActivity wroking

 var activity = (Activity)this.Context; 
     var bar = activityActionBar; 
     var dlp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); 
     bar.CustomView = new Android.Widget.Button(activity) { 
      Text = "Click", 
      LayoutParameters = dlp, 
     }; 
     bar.DisplayOptions = ActionBarDisplayOptions.ShowCustom; 

我應該寫支持FormsAppCompatActivity好嗎?

回答

1

使用FormsAppCompatActivity時,android上的NavigationRenderer會在內部創建一個新的工具欄。這是一個私人領域,目前我可以看到並且無法訪問。

這裏是代碼:https://github.com/xamarin/Xamarin.Forms/blob/d1a8477233b28e6a20c6f5d4a75128ec2a05e6dc/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs

的特定代碼部分中看到的圖像。我現在也在嘗試訪問查看。所以只需要記下你正在編輯的操作欄是錯誤的。這是在活動啓動時創建的。

enter image description here

更新:也許找到了解決方法請看:https://forums.xamarin.com/discussion/69923/access-to-the-formsappcompatactivity-bar

+0

感謝您的! 我可能會很快看看..(問題仍然存在..只有今天看到你的答案!:)) –