Xamarin表单:使用用于android的CustomTabRenderer从所选选项卡隐藏蓝线
我制作了一个自定义渲染器,用于在Android平台的选项卡中显示图像。 现在我想知道如何删除显示选中哪个选项卡的底线。 另外,在哪里可以获得有关创建自定义渲染器的信息?我在youtube上看过,但圆角的例子并没有显示太多Xamarin表单:使用用于android的CustomTabRenderer从所选选项卡隐藏蓝线,xamarin,xamarin.forms,tabbedpage,Xamarin,Xamarin.forms,Tabbedpage,我制作了一个自定义渲染器,用于在Android平台的选项卡中显示图像。 现在我想知道如何删除显示选中哪个选项卡的底线。 另外,在哪里可以获得有关创建自定义渲染器的信息?我在youtube上看过,但圆角的例子并没有显示太多 namespace Plopsa.Android { public class CustomTabRenderer: TabbedRenderer { private Activity _activity; protected override void O
namespace Plopsa.Android
{
public class CustomTabRenderer: TabbedRenderer
{
private Activity _activity;
protected override void OnModelChanged(VisualElement oldModel, VisualElement newModel)
{
base.OnModelChanged(oldModel, newModel);
_activity = this.Context as Activity;
}
// May put this code in a different method - was just for testing
public override void OnWindowFocusChanged(bool hasWindowFocus)
{
// Here the magic happens: get your ActionBar and select the tab you want to add an image
ActionBar actionBar = _activity.ActionBar;
if (actionBar.TabCount > 0)
{
ActionBar.Tab tabOne = actionBar.GetTabAt(0);
tabOne.SetIcon(Resource.Drawable.icon_tab1);
ActionBar.Tab tabTwo = actionBar.GetTabAt(1);
tabTwo.SetIcon (Resource.Drawable.icon_tab2);
ActionBar.Tab tabThree = actionBar.GetTabAt(2);
tabThree.SetIcon(Resource.Drawable.icon_tab3);
ActionBar.Tab tabFour = actionBar.GetTabAt(3);
tabFour.SetIcon(Resource.Drawable.icon_tab4);
}
base.OnWindowFocusChanged(hasWindowFocus);
}
}
通过将Tabbar.axml类“android:tabIndicatorColor”设置为与“android:background”相同的值,可以获得所需的结果 下面是显示所需结果的代码,带有与选项卡背景颜色匹配的选项卡指示器。这些都包含在Tabbar.axml文件中。您可以在MainActivitiy.cs中注册这些选项卡 Tabbar.axml
同样的问题…你能做到吗?在Xamarin中使用API级别23时,ActionBar.Tab已过时。
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.
base.OnCreate(bundle);
Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}