到本地方法類似描述here。這可以使用自定義渲染器完成:
[assembly: ExportRenderer(typeof(TabsPage), typeof(TabsPageRenderer))]
namespace App.Droid.Renderers
{
public class TabsPageRenderer : BadgedTabbedPageRenderer
{
ViewPager _viewPager;
TabLayout _tabLayout;
protected override void OnElementChanged(ElementChangedEventArgs<TabbedPage> e)
{
base.OnElementChanged(e);
for (int i = 0; i < ChildCount; i++)
{
var v = GetChildAt(i);
if (v is ViewPager)
_viewPager = (ViewPager)v;
else if (v is TabLayout)
_tabLayout = (TabLayout)v;
}
_viewPager.SetPageTransformer(true, new NoAnimationPageTransformer());
}
}
public class NoAnimationPageTransformer : Java.Lang.Object, Android.Support.V4.View.ViewPager.IPageTransformer
{
public void TransformPage(Android.Views.View view, float position)
{
if (position < 0)
{
view.ScrollX = (int)((float)(view.Width) * position);
}
else if (position > 0)
{
view.ScrollX = -(int)((float)(view.Width) * -position);
}
else
{
view.ScrollX = 0;
}
}
}
}