我制作了一个自定义渲染器,用于在 Android 平台的选项卡中显示图像。现在我想知道如何删除显示选择了哪个选项卡的底线。另外,我在哪里可以获得有关创建自定义渲染器的信息?我在 youtube 上看过,但圆角的例子并没有显示太多......
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);
}
}