Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Tabbed Page: (Android) Tabs in Landscape NOT as Dropdown menu

$
0
0

Hello guys,

I searched a lot on Google and in this forum, but I didn't found anything. I work with xamarin.forms. In GetMainPage() I create a TabbedPage. Then I add some children which are Content pages:

var csTab = new TabbedPage ();
csTab.Children.Add (new ContentPage{Title = "Title1"});
csTab.Children.Add (new ContentPage{Title = "Title2"});
        // ...etc...
csTab.Children.Add (new  ContentPage{Title = "Titlen"});
return csTab;

I run the app in Android (on a tablet). When I am in landscape mode, the Tabs are presented in a dropdown menu (Because of the number of tabs, the size of the tab bar exceeds the screen size). In portrait mode, all tabs can be seen (side by side) and I have to swipe to get to the tab that I want.

This problem also occurs, when I am not working with xamarin.forms but when I write an app in C# for android only. In this case, the problem can be solved by first implementing the tabs (e.g. by a Method AddTabAdaptor(GenericFragmentPagerAdaptor adaptor,ViewPager pager,string TabText,int ResourceLayout)) and then initialising the actionbar:

var pager = FindViewById<ViewPager> (Resource.Id.pager);
var adapter = new GenericFragmentPagerAdaptor (SupportFragmentManager);

AddTabAdaptor (adaptor,pager, "Title1",Resource.Layout.Title1);
AddTabAdaptor (adaptor,pager, "Title2", Resource.Layout.Title2);
// ... etc...
AddTabAdaptor (adaptor,pager, "Titlen", Resource.Layout.Titlen);

this.ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;

pager.Adapter = adapter;
pager.SetOnPageChangeListener (new ViewPageListenerForActionBar (ActionBar));

But How can I solve the problem with Xamarin.forms??? Thanks in advance.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>