Erma Isabel
Erma Isabel

Reputation: 2177

Xamarin : set different background to each tab (in TabHost)

I am trying to add background to each tab in TabHost.

private void CreateTab(Type activityType, string tag, string label, int drawableId)
    {
        TabHost.TabSpec spec;

        var intent = new Intent(this, activityType);
        intent.AddFlags(ActivityFlags.NewTask);

        spec = TabHost.NewTabSpec(tag);
        var drawableIcon = Resources.GetDrawable(drawableId);
        spec.SetIndicator(label, drawableIcon);
        spec.SetContent(intent);

        TabHost.AddTab(spec);
    }

I use the above code to create tabs.

Please help, Thanks.

Upvotes: 0

Views: 1413

Answers (1)

Erma Isabel
Erma Isabel

Reputation: 2177

I Got it working, Here is the code

TabWidget.GetChildAt(0).SetBackgroundColor(Color.PaleGreen); //1st tab

Upvotes: 1

Related Questions