【问题标题】:xamarin forms change the selected Tab color Textxamarin 表单更改选定的选项卡颜色文本
【发布时间】:2018-07-16 02:54:13
【问题描述】:

我正在使用 Xamarin 跨平台标签页。 我想更改选定的标签颜色文本。 我可以更改背景和文本颜色。 我需要更改所选的 Tab 颜色 Text。 这是我的代码

var page = new tabPage()
                    {
                        BarBackgroundColor = Color.WhiteSmoke,
                        BarTextColor = Color.Black
                    };


<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="ABCAPP.Views.MainPage"  >
    <!--Pages can be added as references or inline-->

    <ContentPage Title="ALL"  >
    </ContentPage>

<ContentPage Title="Email"   >
</ContentPage>

 <ContentPage Title="phoe"   >
</ContentPage>

如果我们选择“Email”,我想改变“Email”的文字颜色。 我该怎么做?

【问题讨论】:

    标签: c# xamarin mobile


    【解决方案1】:

    Xaml 代码:

    <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:App3"
             x:Class="App3.MainPage"
            BarBackgroundColor="Yellow"> 
        <local:Page1/>
        <local:Page1/>
    </TabbedPage>
    

    对于安卓:

    使用 app:tabSelectedTextColor="@color/accent_material_light"app:tabTextColor="@color/accent_material_dark" 属性以更改所选选项卡的文本颜色。(从您提供的代码中删除 BarTextColor = Color.Black。)

    在您的资源文件夹内 -> 布局文件夹 -> Tabbar.axml
    以下代码:

    <?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"
    android:id="@+id/sliding_tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:tabIndicatorColor="@android:color/white"
    app:tabGravity="fill"
    app:tabSelectedTextColor="@color/accent_material_light"
    app:tabTextColor="@color/accent_material_dark"
    app:tabMode="fixed" />
    

    希望这可以解决您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-26
      • 2022-01-20
      相关资源
      最近更新 更多