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

TabbedRenderer - ICONS are not showing when clicking in a navigation page and click back

$
0
0

Hello, this is a tabbed render for show icons in Android, i can't see the icons when clicking in a navigation page and then click back (if i click in one tab can see the icons)


public class CustomTabRenderer : TabbedRenderer
{

private Activity activity;
private const string COLOR = "#FFFFFF";
private const string TEXTCOLOR = "#000000";
private bool isFirstDesign = true;
//This flag is used in the case when the app is not completely closed, and the user return back.


protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
    base.OnElementPropertyChanged(sender, e);
    activity = this.Context as Activity;

    ActionBar actionBar = activity.ActionBar;

    ColorDrawable colorDrawable = new ColorDrawable(global::Android.Graphics.Color.ParseColor(COLOR));
    actionBar.SetStackedBackgroundDrawable(colorDrawable);
    if (actionBar.TabCount > 0) {
        ActionBarTabsSetup (actionBar);
    }

}

private void ActionBarTabsSetup(ActionBar actionBar)
{
    try {

            Android.App.ActionBar.Tab avatar = actionBar.GetTabAt(0);
            if (TabIsEmpty (avatar)) {
                //avatar.SetIcon (Resource.Drawable.nav_statss);

                TabSetup(avatar, Resource.Drawable.search);
            }

            Android.App.ActionBar.Tab contacts = actionBar.GetTabAt(1);
            if (TabIsEmpty (contacts)) {
                //contacts.SetIcon (Resource.Drawable.nav_notification);
                //contacts.SetText ("Notifications");
                TabSetup(contacts, Resource.Drawable.search_active40x40);
                //actionBar.SelectTab (contacts);

            }

            Android.App.ActionBar.Tab favorites = actionBar.GetTabAt(2);
            if (TabIsEmpty(favorites))
                favorites.SetIcon (Resource.Drawable.nav_images);


            Android.App.ActionBar.Tab callsLog = actionBar.GetTabAt(3);
            if (TabIsEmpty(callsLog))
                callsLog.SetIcon (Resource.Drawable.search_default);
                //TabSetup(callsLog, Resource.Drawable.avatar);
        //  callsLog.SetText ("Upload");

            Android.App.ActionBar.Tab test = actionBar.GetTabAt(4);
            if (TabIsEmpty(test))
                test.SetIcon (Resource.Drawable.nav_account);
                //TabSetup(callsLog, Resource.Drawable.avatar);
            //    test.SetText ("Account");

    } catch (Exception ex) {

    }

}

private bool TabIsEmpty(ActionBar.Tab tab)
{
    if (tab != null)
    if (tab.CustomView == null)
        return true;
    return false;
}

private void TabSetup(ActionBar.Tab tab, int resourceID)
{
    ImageView iv = new ImageView(activity);
    iv.SetImageResource(resourceID);
    //iv.SetPadding(-50, 10, -50, 20);
    iv.SetPadding(-35, 8, -35, 16);
    iv.SetMinimumWidth (20);
    tab.SetCustomView(iv);
}

}
}

Best regards


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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