如果我在不同的选项卡之间切换,我总是会得到这个看起来像阴影或某物的小点击动画。我为外壳使用自定义渲染器,但如何禁用此动画?
这是点击动画的图片
我自己找到了解决方案。这是我的代码:
public void ResetAppearance(BottomNavigationView bottomView)
{
}
public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance)
{
Android.Graphics.Color elevationBGColor = ((Color)Xamarin.Forms.Application.Current.Resources["ElevationBGColor"]).ToAndroid();
bottomView.LabelVisibilityMode = LabelVisibilityMode.LabelVisibilityUnlabeled;
bottomView.SetBackgroundColor(elevationBGColor);
int[][] Tintstates = new int[][]
{
new int[] {-Android.Resource.Attribute.StateChecked}, // unchecked
new int[] { Android.Resource.Attribute.StateChecked} // pressed
};
int[] Tintcolors = new int[]
{
Xamarin.Forms.Color.White.ToAndroid(),
((Color)Xamarin.Forms.Application.Current.Resources["PrimaryColor"]).ToAndroid()
};
ColorStateList TintList = new ColorStateList(Tintstates, Tintcolors)
bottomView.ItemIconTintList = TintList;
bottomView.ItemRippleColor = null;
}
在这个代码中,我还为我在导航栏中选择的项目设置了颜色更改,但我搜索的代码是
bottomView.ItemRippleColor = null;