[英]Xamarin Forms change the tabbar size
您可以使用自定義渲染器為TabbedPage
創建渲染器,然后在渲染器中您可以這樣編碼:
public class StyledTabbedPageRenderer : TabbedPageRenderer
{
private Android.Views.View formViewPager = null;
private TabLayout tabLayout = null;
protected override void OnElementChanged(ElementChangedEventArgs<TabbedPage> e)
{
base.OnElementChanged(e);
this.tabLayout = (TabLayout)this.GetChildAt(1);
changeTabsFont();
}
private void changeTabsFont()
{
//Typeface font = Typeface.CreateFromAsset(Android.App.Application.Context.Assets, "fonts/" + Constants.FontStyle);
ViewGroup vg = (ViewGroup)tabLayout.GetChildAt(0);
int tabsCount = vg.ChildCount;
for (int j = 0; j < tabsCount; j++)
{
ViewGroup vgTab = (ViewGroup)vg.GetChildAt(j);
int tabChildsCount = vgTab.ChildCount;
for (int i = 0; i < tabChildsCount; i++)
{
Android.Views.View tabViewChild = vgTab.GetChildAt(i);
if (tabViewChild is TextView)
{
//((TextView)tabViewChild).Typeface = font;
((TextView)tabViewChild).TextSize = 6;
}
}
}
}
}
你也可以參考我的另一個關於自定義TabbedPage
案例:
我認為您需要自定義樣式並更改選項卡中的文本大小。
類似的東西:
<style name="MyTab" parent="@android:style/Widget.Holo.ActionBar.TabText">
<item name="android:textSize"></item>
</style>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.