new here. I need help figuring out why my xamarin project is not reading any of the changes I make to the Tabbar.xml file. Everything was working fine until I decided to add a splash screen style. It could have been something else but that is the only major change I have done to my project, unless I deleted something i wasn't supposed to. Regardless I will be showing those changes as well. I was thinking of just making a custom renderer to avoid this headache, but not I really am curious why this is occurring. Also the unselected tint color has defaulted to white. I can try to change that on the Tabbar.xml side but it does not update. Only the selectedTabcolor changes but because I set that in the <TabbedPage></TabbedPage>
itself. All I want is to have the Text color of the unselected tabs to default the grey that the tab icons seem to defult to, that's how it used to be, and set the selectedTabcolor and TabIndicatorColor to the same color which is #008000.
MainActivity
[Activity(Label = "Weather App", Icon = "@mipmap/icon", Theme = "@style/MainTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.SetTheme(Resource.Style.MainTheme);
base.OnCreate(savedInstanceState);
CrossCurrentActivity.Current.Init(this, savedInstanceState);
Rg.Plugins.Popup.Popup.Init(this);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
SplashScreen
[Activity(Label = "Weather App", Icon = "@mipmap/icon", Theme ="@style/SplashTheme", MainLauncher = true)]
public class SplashActivity : AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
var intent = new Intent(this, typeof(MainActivity));
StartActivity(intent);
Finish();
}
}
Styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
<item name="colorPrimary">#efefef</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#008000</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#019501</item>
</style>
<!-- SPLASH SCREEN -->
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splash_screen</item>
</style>
</resources>
Tabbar.xml
<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="?android:attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabTextColor="@android:color/black"
app:tabIndicatorHeight="2dp"
app:tabIndicatorColor="#008000"
/>
EDIT: As request here is an image of how my tabbar looks like:
I also removed the SelectedTabColor from the <TabbedPage>
itself and added on those changes to the Tabbar.xml and this is the result. I can't get the text color, nor the indicator color nor the selected color to change through the Tabbar. I believe my Tabbar.xaml page is just not being read.
question from:
https://stackoverflow.com/questions/65876918/tabbar-stopped-showing-any-modifications-made-to-the-tabbar-file-in-xamarin-lao 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…