我正在使用 Xamarin 跨平台表单标签页。我想更改选定的选项卡颜色文本。我可以更改背景和文本颜色。 我需要更改选定的选项卡颜色文本。 这是我的代码
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>
Run Code Online (Sandbox Code Playgroud)
如果我们选择“电子邮件”,我想更改“电子邮件”,文本颜色。我该怎么做 ?
Xml代码:
<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>
Run Code Online (Sandbox Code Playgroud)
对于 Android:
使用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" />
Run Code Online (Sandbox Code Playgroud)
希望这可以解决您的问题。
| 归档时间: |
|
| 查看次数: |
5884 次 |
| 最近记录: |