我正在尝试为CustomRenderer
创建一个Android TabbedPage
最后一个标签的颜色不同。
但是,以下代码无法正常工作。我该如何解决这个问题?
protected override void OnVisibilityChanged(Android.Views.View changedView, [GeneratedEnum] ViewStates visibility)
{
base.OnVisibilityChanged(changedView, visibility);
if(visibility == ViewStates.Visible)
{
var tabs = changedView.FindViewById<TabLayout>(Resource.Id.sliding_tabs);
ViewGroup vg = (ViewGroup)tabs.GetChildAt(0);
ViewGroup vgTab = (ViewGroup)vg.GetChildAt(vg.ChildCount - 1);
for (int i = 0; i < vgTab.ChildCount; i++)
{
Android.Views.View tabViewChild = vgTab.GetChildAt(i);
if(tabViewChild is Android.Widget.ImageView)
{
(tabViewChild as Android.Widget.ImageView).SetBackgroundColor(Android.Graphics.Color.Red);
}
}
}
}
答案 0 :(得分:0)
所以,解决方案很简单
51-1