private void RefreshTabs() { for (int i = 0; i < _TabLayout.TabCount; i++) { TabLayout.Tab tab = _TabLayout.GetTabAt(tabFrags[i].Position); tab.SetCustomView(null); tab.SetCustomView(_Adapter.GetTabView(tabFrags[i].Position)); } }
// 탭 레이아웃 설정 public async void SetupTabLayout(Task messageLoadTsk) { var viewPager = activity.FindViewById <ViewPager>(Resource.Id.ma_pager); _TabLayout = activity.FindViewById <TabLayout>(Resource.Id.ma_sliding_tabs); _Adapter = new CustomPagerAdapter(activity.BaseContext, fm); _Adapter.AddTab(tabFrags); // Set adapter to view ma_pager viewPager.Adapter = _Adapter; // Setup tablayout with view ma_pager _TabLayout.SetupWithViewPager(viewPager); //모든 탭에 커스텀 뷰 적용 for (int i = 0; i < _TabLayout.TabCount; i++) { TabLayout.Tab tab = _TabLayout.GetTabAt(tabFrags[i].Position); tab.SetCustomView(_Adapter.GetTabView(tabFrags[i].Position)); } _TabLayout.TabSelected += TabLayout_TabSelected; _TabLayout.TabUnselected += TabLayout_TabUnselected; await messageLoadTsk; RefreshLayout(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.main); btnBloggerSearch = FindViewById <Button>(Resource.Id.btn_blogger_search); btnBloggerSearch.Click += delegate { StartActivity(new Intent(this, typeof(BloggerSearchActivity))); }; pagerAdapter = new SimpleFragmentPagerAdapter(SupportFragmentManager, this); viewPager = FindViewById <ViewPager>(Resource.Id.viewpager); //设置ViewPager缓存Fragment数量 //viewPager.OffscreenPageLimit = 4; viewPager.Adapter = pagerAdapter; tabLayout = FindViewById <TabLayout>(Resource.Id.sliding_tabs); tabLayout.SetupWithViewPager(viewPager); tabLayout.TabMode = TabLayout.ModeFixed; for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); tab.SetCustomView(pagerAdapter.GetTabView(i)); } btn_menu = FindViewById <Button>(Resource.Id.title_bar_left_menu); btn_menu.Click += delegate { StartActivity(new Intent(this, typeof(PersonalCenterActivity))); }; //slideMenu(); //bindMenu(); }
protected override void OnCreate(Bundle bundle) { PreCreate(); ImageToScreenRatio = 0.5F; InitView(Resource.Layout.MovieInfoView, bundle); var mAdView = FindViewById <AdView>(Resource.Id.adView); var adRequest = new AdRequest.Builder().Build(); mAdView.LoadAd(adRequest); string castName = Intent.GetStringExtra("castName"); int castId = Intent.GetIntExtra("castId", 0); Title = castName; var image = FindViewById <ImageView>(Resource.Id.backdrop); Helper.SetImage(this, Intent.GetStringExtra("imageUrl"), image, Resource.Drawable.NoCast); image.Click += Image_Click;; var mViewPager = FindViewById <ViewPager>(Resource.Id.viewpager); var mTabLayout = FindViewById <TabLayout>(Resource.Id.tabs); var tabPagerAdapter = new CastPagerAdapter(this, SupportFragmentManager, castName, castId); mViewPager.Adapter = tabPagerAdapter; mTabLayout.SetupWithViewPager(mViewPager); for (int i = 0; i < mTabLayout.TabCount; i++) { TabLayout.Tab tab = mTabLayout.GetTabAt(i); tab.SetCustomView(tabPagerAdapter.GetTabView(toolbar, i)); } }
protected override void SetTabIcon(TabLayout.Tab tab, FileImageSource icon) { base.SetTabIcon(tab, icon); tab.SetCustomView(Resource.Layout.mytablayout); var imagebtn = tab.CustomView.FindViewById <ImageButton>(Resource.Id.closebtn); imagebtn.SetBackgroundDrawable(tab.Icon); var title = tab.CustomView.FindViewById <TextView>(Resource.Id.tabtitle); title.Text = tab.Text; imagebtn.Click += (sender, e) => { var closebtn = sender as ImageButton; var parent = closebtn.Parent as Android.Widget.RelativeLayout; var closingtitle = parent.FindViewById <TextView>(Resource.Id.tabtitle); foreach (var child in children) { var page = child as ContentPage; if (page.Title == closingtitle.Text) { children.Remove(child); break; } } }; }
private void setCustomTabs(int complete, int pending, int cancel) { for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); View tabView = ((ViewGroup)tabLayout.GetChildAt(0)).GetChildAt(i); tabView.RequestLayout(); var view = LayoutInflater.From(Context).Inflate(Resource.Layout.CustomTabReservation, null); TextView txt_day = view.FindViewById <TextView>(Resource.Id.txt_tab_reservation); ImageView img = view.FindViewById <ImageView>(Resource.Id.img_tab_reservation); if (i == 0) { txt_day.Text = (complete.ToString()); img.SetImageResource(Resource.Drawable.ic_complete); } else if (i == 1) { txt_day.Text = (pending.ToString()); img.SetImageResource(Resource.Drawable.ic_pending); } else if (i == 2) { txt_day.Text = (cancel.ToString()); img.SetImageResource(Resource.Drawable.ic_cancel); } tab.SetCustomView(view); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.Inflate(Resource.Layout.EventDetails, container, false); var pager = view.FindViewById <ViewPager>(Resource.Id.pager); var tabLayout = view.FindViewById <TabLayout>(Resource.Id.tabs); var imageSlider = view.FindViewById <ViewPager>(Resource.Id.imageSlider); Bitmap[] images = new Bitmap[] { GetImageBitmapFromUrl("http://" + MainActivity.ip + "/shindyAdmin/assets/images/rock.jpg"), GetImageBitmapFromUrl("http://" + MainActivity.ip + "/shindyAdmin/assets/images/car1.jpg"), GetImageBitmapFromUrl("http://" + MainActivity.ip + "/shindyAdmin/assets/images/car2.jpg"), GetImageBitmapFromUrl("http://" + MainActivity.ip + "/shindyAdmin/assets/images/car3.jpg") }; ImageAdapter imageAdapter = new ImageAdapter(this.Context, images); var inviteFriends_button = view.FindViewById <ImageButton>(Resource.Id.sendInvite_button); inviteFriends_button.Click += InviteFriends_button_Click; imageSlider.Adapter = imageAdapter; var adapter = new EventDetailsPagerAdapter(this.Context, Activity.SupportFragmentManager, new String[] { "Details", "Discussion", "Reviews" }, 3); pager.Adapter = adapter; pager.OffscreenPageLimit = 2; tabLayout.SetupWithViewPager(pager); for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); tab.SetCustomView(adapter.GetTabView(i)); } return(view); }
public void SetupViewPager(View view) { var viewPager = view.FindViewById <ViewPager>(Resource.Id.viewpager); if (viewPager != null) { var fragments = new List <MvxViewPagerFragmentAdapter.FragmentInfo> { new MvxViewPagerFragmentAdapter.FragmentInfo { FragmentType = typeof(TaskListFragment), Title = "", ViewModel = ViewModel.TaskListViewModel }, new MvxViewPagerFragmentAdapter.FragmentInfo { FragmentType = typeof(AboutFragment), Title = "", ViewModel = ViewModel.AboutViewModel }, }; var adapter = new MvxViewPagerFragmentAdapter(Activity, ChildFragmentManager, fragments); viewPager.Adapter = adapter; var tabLayout = view.FindViewById <TabLayout>(Resource.Id.tabs); tabLayout.SetupWithViewPager(viewPager); tabLayout.DrawingCacheBackgroundColor = Color.Black; for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); tab.SetCustomView(adapter.GetTabView(i)); } } }
protected override void OnCreate(Bundle bundle) { try { InitView(Resource.Layout.Search, bundle); adRenderer.RenderAd(FindViewById <AdView>(Resource.Id.adView)); Title = ""; bundle = new Bundle(); bundle.PutString("query", Intent.GetStringExtra("query")); var viewPager = (ViewPager)FindViewById(Resource.Id.viewpager); viewPager.OffscreenPageLimit = 0; var tabLayout = (TabLayout)FindViewById(Resource.Id.tabs); var tabPagerAdapter = new SearchPagerAdapter(this, SupportFragmentManager, ""); viewPager.Adapter = tabPagerAdapter; tabLayout.SetupWithViewPager(viewPager); for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); tab.SetCustomView(tabPagerAdapter.GetTabView(toolbar, i)); } SetupSearchView(viewPager, tabLayout); } catch (Exception ex) { Toast.MakeText(Application.Context, ex.ToString(), ToastLength.Long).Show(); } }
private void InitTabView() { View rootView = LayoutInflater.From(context).Inflate(Resource.Layout.tab_with_badge, null); tabView.SetCustomView(rootView); SetBadgeCount(badge); SetTitleContent(title); }
protected override void OnCreate(Bundle savedInstanceState) { //socket.Connect().Emit("new user", "Akomaister"); base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var house_name = Intent.GetStringExtra("House_name"); string house_id = Intent.GetStringExtra("House_id"); var tabLayout = FindViewById <TabLayout>(Resource.Id.sliding_tabs); var pager = FindViewById <ViewPager>(Resource.Id.pager); var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar1); var adapter = new CustomPagerAdapter(this, SupportFragmentManager, house_name, house_id, socket); //Toolbar will now take on default actionbar characteristics SetSupportActionBar(toolbar); if (house_name == "" || house_name == null) { SupportActionBar.Title = "Id: " + house_id; } else { SupportActionBar.Title = house_name; } SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); toolbar.SetTitleTextAppearance(this, Resource.Style.ActionBarTitle); adapter.SetTabTitles("Devices", "Statistics"); adapter.SetTabIcons(Resource.Drawable.selector_devices, Resource.Drawable.selector_statistics); pager.Adapter = adapter; pager.SetCurrentItem(1, true); // Setup tablayout with view pager tabLayout.SetupWithViewPager(pager); // Iterate over all tabs and set the custom view TabLayout.Tab tab1 = tabLayout.GetTabAt(0); tab1.SetCustomView(adapter.GetTabView(0)); tabLayout.GetTabAt(0).Select(); TabLayout.Tab tab2 = tabLayout.GetTabAt(1); tab2.SetCustomView(adapter.GetTabView(1)); tabLayout.TabSelected += delegate { int pos = tabLayout.SelectedTabPosition; pager.SetCurrentItem(pos, true); adapter.StartThreads(pos); adapter.StopThreads((pos + 1) % 2); }; }
protected override void SetTabIcon(TabLayout.Tab tab, FileImageSource icon) { base.SetTabIcon(tab, icon); tab.SetCustomView(Resource.Layout.MyTabbar); var imageview = tab.CustomView.FindViewById <ImageView>(Resource.Id.icon); imageview.SetBackgroundDrawable(tab.Icon); }
protected override void SetTabIcon(TabLayout.Tab tab, FileImageSource icon) { base.SetTabIcon(tab, icon); tab.SetCustomView(Resource.Layout.MyTabLayout); var imageview = tab.CustomView.FindViewById <ImageView>(Resource.Id.icon); var textview = tab.CustomView.FindViewById <TextView>(Resource.Id.title); imageview.Background = tab.Icon; textview.Text = tab.Text; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Action_bar); mPagerActionBar = FindViewById <ViewPager>(Resource.Id.pagerActionBar); mTabLayout = FindViewById <TabLayout>(Resource.Id.slidingTabsActionBar); mToolbar = FindViewById <SupportToolbar>(Resource.Id.ActionBarToolbar); Bundle intentFormActivity = Intent.Extras; if (intentFormActivity != null) { mHelpVariable = intentFormActivity.GetString("StatsTable"); if (mHelpVariable != null) { mHelpVariable = "StastTable"; mToolbar.Title = "Table statistics"; SetSupportActionBar(mToolbar); SupportActionBar.SetDisplayShowTitleEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); } else { mHelpVariable = intentFormActivity.GetString("StatsColumns"); if (mHelpVariable != null) { mHelpVariable = "StatsColumns"; mToolbar.Title = "Column statistics"; SetSupportActionBar(mToolbar); SupportActionBar.SetDisplayShowTitleEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); } } } mAdapter = new ActionBarFragmentAdapter(this, SupportFragmentManager, mHelpVariable); mPagerActionBar.Adapter = mAdapter; mTabLayout.SetupWithViewPager(mPagerActionBar); for (int position = 0; position < mTabLayout.TabCount; position++) { TabLayout.Tab tab = mTabLayout.GetTabAt(position); tab.SetCustomView(mAdapter.GetTabView(position)); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); //var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar); //SetActionBar(toolbar); //ActionBar.Title = "Clinic"; //OnCreateOptionsMenu(toolbar.Menu); //GradientDrawable test = new GradientDrawable(GradientDrawable.Orientation.RightLeft, new int[] { /*new Color(90, 134, 34),*/ new Color(56, 172, 136), new Color(109, 200, 211), new Color(198, 223, 245), new Color(255, 255, 255) }); //toolbar.SetBackgroundDrawable(test); //var toolbar2 = FindViewById<Toolbar>(Resource.Id.edit_toolbar); //SetActionBar(toolbar2); //ActionBar.Title = "Edit content"; //OnCreateOptionsMenu(toolbar2.Menu); //var editToolbar = FindViewById<Toolbar>(Resource.Id.edit_menus); //editToolbar.Title = "Editing"; //editToolbar.InflateMenu(Resource.Menu.edit_menus); //editToolbar.MenuItemClick += (sender, e) => //{ // Toast.MakeText(this, "Bottom toolbar tapped: " + e.Item.TitleFormatted, ToastLength.Short).Show(); //}; // Find views var pager = FindViewById <ViewPager>(Resource.Id.pager); var tabLayout = FindViewById <TabLayout>(Resource.Id.sliding_tabs); var adapter = new CustomPagerAdapter(this, SupportFragmentManager); // Set adapter to view pager pager.Adapter = adapter; // Setup tablayout with view pager tabLayout.SetupWithViewPager(pager); // Iterate over all tabs and set the custom view for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); tab.SetCustomView(adapter.GetTabView(i)); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); MyContext = this.ApplicationContext; MyActivity = this; Nastaveni.ChorusMany = Nastaveni.GetSetting("ChorusMany"); Nastaveni.Center = Nastaveni.GetSetting("Center"); Nastaveni.BigFont = Nastaveni.GetSetting("BigFont"); Nastaveni.NoLineBreaks = Nastaveni.GetSetting("NoLineBreaks"); DataManager.LoadSongs(); // Set our view from the "main" layout resource SetContentView(Resource.Layout.main); // Find views var pager = FindViewById<ViewPager>(Resource.Id.pager); var tabLayout = FindViewById<TabLayout>(Resource.Id.sliding_tabs); var adapter = new CustomPagerAdapter(this, SupportFragmentManager); //var toolbar = FindViewById<Toolbar>(Resource.Id.my_toolbar); MyPager = pager; //IOnPageChangeListener l = new pager.AddOnPageChangeListener(new MyOnPageChangeListener()); // Setup Toolbar //SetSupportActionBar(toolbar); //SupportActionBar.Title = "Test"; // Set adapter to view pager pager.Adapter = adapter; //pager.SetCurrentItem(0, false); // Setup tablayout with view pager tabLayout.SetupWithViewPager(pager, true); MyTabLayout = tabLayout; Nastaveni.HideHeader = Nastaveni.GetSetting("HideHeader"); Nastaveni.HideStatusBar = Nastaveni.GetSetting("HideStatusBar"); Nastaveni.LockPortrait = Nastaveni.GetSetting("LockPortrait"); // Iterate over all tabs and set the custom view for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); tab.SetCustomView(adapter.GetTabView(i)); } }
private void SetupTabbedView(Android.Support.V7.Widget.Toolbar toolbar) { viewPager = FindViewById <ViewPager>(Resource.Id.viewpager); pagerAdapter = new HomePagerAdapter(this, SupportFragmentManager); viewPager.Adapter = pagerAdapter; tabs = FindViewById <TabLayout>(Resource.Id.tab_layout); tabs.SetupWithViewPager(viewPager); for (int i = 0; i < tabs.TabCount; i++) { TabLayout.Tab tab = tabs.GetTabAt(i); tab.SetCustomView(pagerAdapter.GetTabView(toolbar, i)); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); //BlurView Start root = FindViewById <ViewGroup>(Resource.Id.root); mainBlurView = FindViewById <BlurView>(Resource.Id.mainBlurView); float radius = 0.5F; //set background, if your root layout doesn't have one Drawable windowBackground = Window.DecorView.Background; var topViewSettings = mainBlurView.SetupWith(root) .WindowBackground(windowBackground) .BlurAlgorithm(new RenderScriptBlur(this)) // SupportRenderScriptBlur .BlurRadius(radius) .SetHasFixedTransformationMatrix(true); ////BlurView End // Find views var pager = FindViewById <ViewPager>(Resource.Id.pager); var tabLayout = FindViewById <TabLayout>(Resource.Id.sliding_tabs); var adapter = new CustomPagerAdapter(this, SupportFragmentManager); var toolbar = FindViewById <Toolbar>(Resource.Id.my_toolbar); // Setup Toolbar SetSupportActionBar(toolbar); //SupportActionBar.Title = "Lettre"; SupportActionBar.Hide(); // Set adapter to view pager pager.Adapter = adapter; // Setup tablayout with view pager tabLayout.SetupWithViewPager(pager); // Iterate over all tabs and set the custom view for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); tab.SetCustomView(adapter.GetTabView(i)); } }
void assistant_Idled(object sender, EventArgs e) { MainThread.BeginInvokeOnMainThread(() => { var tabPagerAdapter = new SearchPagerAdapter(context, mgr, newText); mViewPager.Adapter = tabPagerAdapter; mTabLayout.SetupWithViewPager(mViewPager); for (int i = 0; i < mTabLayout.TabCount; i++) { TabLayout.Tab tab = mTabLayout.GetTabAt(i); tab.SetCustomView(tabPagerAdapter.GetTabView(toolbar, i)); } }); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.Inflate(Resource.Layout.Home, container, false); var pager = view.FindViewById <ViewPager>(Resource.Id.pager); var tabLayout = view.FindViewById <TabLayout>(Resource.Id.tabs); var adapter = new CustomPagerAdapter(this.Context, Activity.SupportFragmentManager, new String[] { "My Shindigs", "My Hosted Events" }, 2); pager.Adapter = adapter; tabLayout.SetupWithViewPager(pager); for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); tab.SetCustomView(adapter.GetTabView(i)); } return(view); }
private void InvertLayoutThroughScale() { ViewGroup.ScaleY = -1; TabLayout tabLayout = null; ViewPager viewPager = null; for (int i = 0; i < ChildCount; ++i) { Android.Views.View view = (Android.Views.View)GetChildAt(i); if (view is TabLayout) { tabLayout = (TabLayout)view; } else if (view is ViewPager) { viewPager = (ViewPager)view; } } tabLayout.ScaleY = viewPager.ScaleY = -1; tabLayout.SetPadding(0, -30, 0, 0); viewPager.SetPadding(0, -tabLayout.MeasuredHeight, 0, 0); if (currentTab != tabLayout) { for (int j = 0; j < tabLayout.TabCount; j++) { TabLayout.Tab tab = tabLayout.GetTabAt(j); tab.SetCustomView(Resource.Layout.custom_tab_layout); var imageview = tab.CustomView.FindViewById <ImageView>(Resource.Id.icon); var tv = tab.CustomView.FindViewById <TextView>(Resource.Id.tv); tv.SetText(tab.Text, TextView.BufferType.Normal); imageview.SetBackgroundDrawable(tab.Icon); ColorStateList colors2 = null; if ((int)Build.VERSION.SdkInt >= 23) { colors2 = Resources.GetColorStateList(Resource.Color.icon_tab, Forms.Context.Theme); } else { colors2 = Resources.GetColorStateList(Resource.Color.icon_tab); tv.SetTextColor(colors2); } currentTab = tabLayout; } } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.Inflate(Resource.Layout.InviteFriends, container, false); var pager = view.FindViewById <ViewPager>(Resource.Id.pager); var tabLayout = view.FindViewById <TabLayout>(Resource.Id.tabs); var adapter = new InviteFriendsPagerAdapter(this.Context, Activity.SupportFragmentManager, new String[] { "SEARCH", "INTERESTS", "FB", "INVITE" }, 4, new int[] { Resource.Drawable.ic_search, Resource.Drawable.ic_heart_outline, Resource.Drawable.ic_fb, Resource.Drawable.ic_search }); pager.Adapter = adapter; tabLayout.SetupWithViewPager(pager); tabLayout.SetSelectedTabIndicatorColor(Color.Rgb(253, 202, 46)); pager.OffscreenPageLimit = 2; for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); tab.SetCustomView(adapter.GetTabView(i)); } return(view); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); var pager = FindViewById <ViewPager>(Resource.Id.pager); var tabLayout = FindViewById <TabLayout>(Resource.Id.sliding_tabs); CustomPagerAdapter adapter = new CustomPagerAdapter(this, SupportFragmentManager); pager.Adapter = adapter; // Set adapter to view pager tabLayout.SetupWithViewPager(pager); // Setup tablayout with view pager for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); tab.SetCustomView(adapter.GetTabView(i)); } }
private void setCustomTabs() { tabLayout.AddTab(tabLayout.NewTab().SetText("First")); tabLayout.AddTab(tabLayout.NewTab().SetText("First")); tabLayout.AddTab(tabLayout.NewTab().SetText("First")); tabLayout.AddTab(tabLayout.NewTab().SetText("First")); tabLayout.AddTab(tabLayout.NewTab().SetText("First")); tabLayout.AddTab(tabLayout.NewTab().SetText("First")); tabLayout.AddTab(tabLayout.NewTab().SetText("First")); Calendar calendar = Calendar.Instance; for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); View tabView = ((ViewGroup)tabLayout.GetChildAt(0)).GetChildAt(i); tabView.RequestLayout(); var view = LayoutInflater.From(Context).Inflate(Resource.Layout.custom_tab, null); TextView txt_cal_day = view.FindViewById <TextView>(Resource.Id.txt_cal_day); TextView txt_date = view.FindViewById <TextView>(Resource.Id.txt_date); View viewCircle = view.FindViewById <View>(Resource.Id.view_circle); if (i == 2 || i == 3 || i == 4) { viewCircle.Visibility = ViewStates.Visible; } else { viewCircle.Visibility = ViewStates.Gone; } if (i != 0) { calendar.Add(Calendar.Date, 1); } txt_date.Text = ("" + calendar.Get(Calendar.Date)); txt_cal_day.Text = (Week[calendar.Get(Calendar.DayOfWeek)]); tab.SetCustomView(view); //tab.Text = (i + ""); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.main); var pager = FindViewById <ViewPager>(Resource.Id.pager); var tabLayout = FindViewById <TabLayout>(Resource.Id.sliding_tabs); var adapter = new CustomPagerAdapter(this, SupportFragmentManager); var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.my_toolbar); SetSupportActionBar(toolbar); SupportActionBar.Hide(); pager.Adapter = adapter; tabLayout.SetupWithViewPager(pager); for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); tab.SetCustomView(adapter.GetTabView(i)); } }
private void SetTab(TabLayout.Tab tab, string name) { try { int id = Resources.GetIdentifier(name, "drawable", Context.PackageName); tab.SetIcon(null); LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); linearLayoutParams.SetMargins(0, -48, 0, 0); ImageView img = new ImageView(Context); img.LayoutParameters = linearLayoutParams; img.SetPadding(0, 0, 0, 48); img.SetImageResource(id); tab.SetCustomView(img); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.StackTrace); } }
protected async override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Forms.Init(this, bundle); UserName = Intent.GetStringExtra("USERNAME"); UserPassword = Intent.GetStringExtra("PASSWORD"); // Deactivated local User Database // UserId = Intent.GetIntExtra("USERID", -1); #region Connect to OPC UA Server // when View is created: connect the client to the specified Endpoint Connect(); #endregion // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Find views _pager = FindViewById <ViewPager>(Resource.Id.pager); _tabLayout = FindViewById <TabLayout>(Resource.Id.sliding_tabs); var adapter = new MenuPagerAdapter(this, SupportFragmentManager); _toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); //Setup Toolbar SetSupportActionBar(_toolbar); SetupSupportActionBar(); // Set adapter to view pager and add OnPageChangeListener _pager.Adapter = adapter; _pager.AddOnPageChangeListener(this); // Setup tablayout with view pager _tabLayout.SetupWithViewPager(_pager); // Iterate over all tabs and set the custom view for (int i = 0; i < _tabLayout.TabCount; i++) { TabLayout.Tab tab = _tabLayout.GetTabAt(i); tab.SetCustomView(adapter.GetTabView(i)); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); CurrentPlatform.Init(); byDateFilter = false; byAuthorFilter = false; // Set our view from the "main" layout resource base.SetContentView(PlanYourJourney.Resource.Layout.Main); List = new List <Arrangement>(); UpdateData(); ISharedPreferences settings = GetSharedPreferences("MyPrefsFile", 0); MyUsername = settings.GetString("author", ""); // Find views _pager = FindViewById <ViewPager>(PlanYourJourney.Resource.Id.pager); _tabLayout = FindViewById <TabLayout>(PlanYourJourney.Resource.Id.sliding_tabs); _adapter = new CustomPagerAdapter(this, SupportFragmentManager); _toolbar = FindViewById <Toolbar>(PlanYourJourney.Resource.Id.my_toolbar); // Setup Toolbar SetSupportActionBar(_toolbar); base.SupportActionBar.Title = GetString(PlanYourJourney.Resource.String.app_name); // Set adapter to view pager _pager.Adapter = _adapter; // Setup tablayout with view pager _tabLayout.SetupWithViewPager(_pager); // Iterate over all tabs and set the custom view for (int i = 0; i < 3; i++) { TabLayout.Tab tab = _tabLayout.GetTabAt(i); tab.SetCustomView(_adapter.GetTabView(i)); } }
protected override void SetTabIcon(TabLayout.Tab tab, FileImageSource icon) { base.SetTabIcon(tab, icon); if (tab.Text == "菜单" || tab.Text == "搜索") { tab.SetCustomView(Resource.Layout.CustomTablayout); var customView = Element as CustomTabbedPage; var imagebtn = tab.CustomView.FindViewById <Android.Widget.ImageButton>(Resource.Id.tabpage_btn); imagebtn.Background = tab.Icon; imagebtn.Click += (sender, e) => { if (tab.Text == "菜单") { CustomTabbedPage.OnMenuClicked(customView, EventArgs.Empty); } else if (tab.Text == "搜索") { CustomTabbedPage.OnSearchClick(customView, EventArgs.Empty); } }; } }