D.A.KANG
D.A.KANG

Reputation: 265

set tabbedpage's actionbar's text size

making first tabbed page code 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>

add tabbed page code 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>

I make tabbedPage using Xamarin Sample.

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

but if make many tabbed page,

tabbed page's action bar's title text do 2 line

(ex. programmer

->prog rammer)

I want set actionbar's font size, not use custom renderer how can I do this?

Upvotes: 1

Views: 1158

Answers (1)

Joshua Poling
Joshua Poling

Reputation: 571

If you're looking to set the font size for all tabs you can do it in the Android TabLayout.xml

Create a style for your tabs.

  <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>

Assign the style to your tab view

<?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" />

Upvotes: 1

Related Questions