question

6666666 avatar image
0 Votes"
6666666 asked JessieZhang-2116 commented

how to remove the animation of the android ?

89730-qq%E6%88%AA%E5%9B%BE20210421112258.png

after tap the menu there will be a animation like weaves how to remove it? in xamarin.android

and the active font size will be larger than that is not active how to make the two menu font size equal?

and how to remove the title name 我的 If I long-time tap the menu?

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JessieZhang-2116 avatar image
0 Votes"
JessieZhang-2116 answered JessieZhang-2116 commented

Hello,


Welcome to our Microsoft Q&A platform!

the active font size will be larger than that is not active how to make the two menu font size equal?

You can use Shell custom renderers to change tab bar text size and change icon.

Please refer to the following code:

1.In android, create MyShellRenderer

 [assembly: ExportRenderer(typeof(AppShell), typeof(MyShellRenderer))]
 namespace shellicon.Droid
 {
 public class MyShellRenderer : ShellRenderer
 {
     public MyShellRenderer(Context context) : base(context)
     {
     }
    
     protected override IShellBottomNavViewAppearanceTracker CreateBottomNavViewAppearanceTracker(ShellItem shellItem)
     {
         return new CustomBottomNavAppearance();
     }
 }
    
 public class CustomBottomNavAppearance : IShellBottomNavViewAppearanceTracker
 {
     public void Dispose()
     {    
     }
     public void ResetAppearance(BottomNavigationView bottomView)
     {
         throw new NotImplementedException();
     }       
     public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance)
     {
         var instance = MainActivity.mactivity;
         int width = instance.width;
    
         if(width>??)
         {
             var bottomNavMenuView = bottomView.GetChildAt(0) as BottomNavigationMenuView;
    
             for (int i = 0; i < bottomNavMenuView.ChildCount; i++)
             {
                 var item = bottomNavMenuView.GetChildAt(i) as BottomNavigationItemView;
                 var itemicon = item.GetChildAt(0);
                 var itemTitle = item.GetChildAt(1);
    
                 var IconImageView = (ImageView)itemicon;
                 var smallTextView = ((TextView)((BaselineLayout)itemTitle).GetChildAt(0));
                 var largeTextView = ((TextView)((BaselineLayout)itemTitle).GetChildAt(1));
    
                 IconImageView.SetImageResource(Resource.Drawable.check);
                 smallTextView.TextSize = 18;
                 largeTextView.TextSize = 18;
    
             }
         }
           
     }
 }

2.Getting current screen size in Mainactivity.cs:

 public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
 {
     public static MainActivity mactivity;
     public int width { get; set; }
     protected override void OnCreate(Bundle savedInstanceState)
     {
         TabLayoutResource = Resource.Layout.Tabbar;
         ToolbarResource = Resource.Layout.Toolbar;
    
         base.OnCreate(savedInstanceState);
    
         Xamarin.Essentials.Platform.Init(this, savedInstanceState);
         global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
         LoadApplication(new App());
           
         var metrics = Resources.DisplayMetrics;
         width = metrics.WidthPixels;
         mactivity = this;
     }
     public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
     {
         Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    
         base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
     }
 }

Best Regards,

Jessie Zhang


If the response is helpful, please click "Accept Answer" and upvote it.


Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you @JessieZhang-2116 But I am not using Shell just Xamarin.Forms.Android.

0 Votes 0 ·

Could you please post a basic demo to github or onedriver so that we can test on our side?

0 Votes 0 ·

It will be great if you can share a basic demo to github or onedriver for us to better investigate this issue. Thanks for your cooperation.

0 Votes 0 ·

I have not heard from you for a couple of days. Please let me know if there is anything that I can help here.

0 Votes 0 ·