我想更改MainPage.xaml 中的 tabindicatorcolor, 但我看不到屬性 tabindicatorcolor。他們在這里提到使用AppCompat,我已經從 NuGet 匯入了 Android 支持庫 v7 AppCompat 并提到在這里 檢查它Resources/layout/Tabbar.axml但我在 MyProject.Android 專案中看不到。
我還錯過了什么?抱歉,剛接觸編程。編輯:我使用 Xamarin.Forms
uj5u.com熱心網友回復:
在 Xamarin.Forms 專案的 Android 平臺的 Resources 檔案夾中創建一個布局檔案夾。
然后tabbar.xml在布局檔案夾中創建。為檔案添加以下代碼。我將指示器顏色設定為紅色以供參考。
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.tabs.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="#FF3300"
app:tabGravity="fill"
app:tabMode="fixed" />
并且不要忘記TabLayoutResource在 MainActivity 中設定。
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
TabLayoutResource= Resource.Layout.tabbar;
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
目前,當您在 Xamarin.Forms 中使用選項卡頁面時,您將擁有紅色 tabindicatorcolor。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/396673.html
標籤:C# 安卓 视觉工作室 沙马林 xamarin.forms
下一篇:Flutter-卡片高程無陰影
