【问题标题】:set tabbedpage's actionbar's text size设置标签页的操作栏的文本大小
【发布时间】:2017-04-12 09:58:40
【问题描述】:

制作第一个标签页代码xaml

<?xml version="1.0" encoding="utf-8" ?>

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="ElronWebtoon_Test.Page1Tab1"
         Title="All">

</ContentPage>

添加标签页代码xaml

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="ElronWebtoon_Test.Page1"
             xmlns:pages="clr-namespace:ElronWebtoon_Test;assembly=ElronWebtoon_Test"
             Title="TabbedPage">
  <!--Pages can be added as references or inline-->
  <pages:Page1Tab1/>
    <ContentPage Title="tab1">
        <Grid>

            <StackLayout x:Name="romance">
                <Label Text="Green" HorizontalTextAlignment="Center" HorizontalOptions="FillAndExpand" Margin="5"  />
                <BoxView Color="Green" VerticalOptions="FillAndExpand" />
            </StackLayout>
        </Grid>
    </ContentPage>


    <ContentPage Title="tab2">
        <Grid>               
            <StackLayout>
                <Label Text="Blue" HorizontalTextAlignment="Center" HorizontalOptions="FillAndExpand" Margin="5"  />
                <BoxView Color="Blue" VerticalOptions="FillAndExpand" />
            </StackLayout>
        </Grid>
    </ContentPage>


    <ContentPage Title="tab3">
        <Grid>              
            <StackLayout>
                <Label Text="Pink" HorizontalTextAlignment="Center" HorizontalOptions="FillAndExpand" Margin="5"  />
                <BoxView Color="Pink" VerticalOptions="FillAndExpand" />
            </StackLayout>
        </Grid>
    </ContentPage>

</TabbedPage>

我使用 Xamarin 示例制作 tabbedPage。

(https://developer.xamarin.com/samples/xamarin-forms/Navigation/TabbedPageWithNavigationPage/)

但如果制作多个标签页,

标签页的操作栏的标题文本做 2 行

(例如程序员

->编 夯)

我想设置操作栏的字体大小,而不是使用自定义渲染器 我该怎么做?

【问题讨论】:

    标签: xamarin.android android-actionbar tabbedpage


    【解决方案1】:

    如果您希望为所有选项卡设置字体大小,您可以在 Android TabLayout.xml 中进行设置

    为您的标签创建样式。

      <style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
        <item name="tabTextAppearance">@style/MyCustomTabText</item>
      </style>
    
      <style name="MyCustomTabText" parent="TextAppearance.AppCompat.Button">
        <item name="android:textSize">10sp</item>
        <item name="android:textColor">@color/primaryDark</item>
      </style>
    

    将样式分配给您的标签视图

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        app:tabTextAppearance="@style/MyCustomTabText"
        android:id="@+id/sliding_tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Light"
        app:tabTextColor="@color/primaryDark"
        app:tabIndicatorColor="?attr/colorPrimary"
        app:tabIndicatorHeight="0dp"
        app:tabSelectedTextColor="@color/primaryDark"
        app:tabGravity="fill"
        app:tabMode="fixed" />
    

    【讨论】:

      猜你喜欢
      • 2014-07-23
      • 1970-01-01
      • 1970-01-01
      • 2012-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多