表单Android Tabbar自定义图标和文本
我已通过以下链接检查并实施: 现在我可以看到文字上方的图像。我想增加tabbar的高度,使图标具有更大的尺寸。 我还检查了&。我试图在我的Xamarin.Forms项目中实现AppCompative活动。 起初,android活动源于表单Android Tabbar自定义图标和文本,android,android-actionbar,xamarin.forms,tabpage,android-appcompat,Android,Android Actionbar,Xamarin.forms,Tabpage,Android Appcompat,我已通过以下链接检查并实施: 现在我可以看到文字上方的图像。我想增加tabbar的高度,使图标具有更大的尺寸。 我还检查了&。我试图在我的Xamarin.Forms项目中实现AppCompative活动。 起初,android活动源于global::Xamarin.Forms.Platform.android.FormsApplicationActivity,现在它被转换为global::Xamarin.Forms.Platform.android.FormsApplicationActivit
global::Xamarin.Forms.Platform.android.FormsApplicationActivity
,现在它被转换为global::Xamarin.Forms.Platform.android.FormsApplicationActivity
。
并且为TabbedPage
实现了自定义渲染器。我知道它必须转换为TabbedPageRender
才能进行AppCompatActivity
。所以我也更新了渲染器。
但是现在没有调用自定义渲染器。而且我无法更改AppCompatActivity
中放置在ActionBar
中的选项卡栏的高度。
让我知道我做错了什么。
谢谢。如果您有代码,请发布
protected override void OnElementChanged(ElementChangedEventArgs<TabbedPage> e)
{
base.OnElementChanged(e);
var fieldInfo = typeof (TabbedPageRenderer).GetField("_tabLayout", BindingFlags.Instance | BindingFlags.NonPublic);
System.Diagnostics.Debug.Assert(fieldInfo != null, "fieldInfo != null");
_myTabLayout = (TabLayout) fieldInfo.GetValue(this);
// Uncomment to Disable scrolling
//var propInfo = typeof (TabbedPageRenderer).GetProperty("UseAnimations", BindingFlags.Instance | BindingFlags.NonPublic);
//propInfo.SetValue(this, false);
if (e.OldElement != null)
{
}
if (e.NewElement != null)
{
if (_myTabLayout.TabCount != this.Element.Children.Count)
return;
for (int index = 0; index < this.Element.Children.Count; ++index)
{
_myTabLayout.GetTabAt(index).SetText("");
FileImageSource icon = this.Element.Children[index].Icon;
if (string.IsNullOrEmpty(icon))
continue;
var imageView = new AppCompatImageView(this.Context);
imageView.SetPadding(4, 4, 4, 4);
var drawable = ResourceManager.GetDrawableByName(icon.File);
imageView.SetImageResource(drawable);
_myTabLayout.GetTabAt(index).SetCustomView(imageView);
}
_myTabLayout.GetTabAt(0).Select();
}
}
protected override void OnElementChanged(ElementChangedEventArgs e)
{
基础。一个要素发生变化(e);
var fieldInfo=typeof(TabbedPageRenderer.GetField(“_tabLayout”,BindingFlags.Instance | BindingFlags.NonPublic);
System.Diagnostics.Debug.Assert(fieldInfo!=null,“fieldInfo!=null”);
_myTabLayout=(TabLayout)fieldInfo.GetValue(此);
//取消注释以禁用滚动
//var propInfo=typeof(TabbedPageRenderer.GetProperty(“UseAnimations”,BindingFlags.Instance | BindingFlags.NonPublic);
//propInfo.SetValue(该值为false);
if(e.OldElement!=null)
{
}
if(例如NewElement!=null)
{
if(_myTabLayout.TabCount!=this.Element.Children.Count)
返回;
for(int index=0;index
}寻求调试帮助的问题(“为什么这段代码不起作用?”)必须包括所需的行为、特定的问题或错误以及在问题本身中重现它所需的最短代码。没有明确问题陈述的问题对其他读者没有用处。见: