Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] Android TabLayOut is not picking up colorPrimary

Posted on November 11, 2022 By

Solution 1 :

Use tabBackground

app:tabBackground="@color/colorPrimary"

Problem :

Android tab layout background color is white when it should be trasparent.

enter image description here

It won’t pick up the colorPrimary in the below code:

             <?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" // Should pick up transparent 
                 here?
                 android_theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                 android_backgroundTint="#5C328A"
                 app_tabTextColor="@color/button_material_light"
                 app_tabSelectedTextColor="@android:color/black"
                 app_tabIndicatorColor="@android:color/white"
                 app_tabGravity="fill"
                 app_tabMode="fixed" />

colors.xml:

            <?xml version="1.0" encoding="utf-8"?>
            <resources>
               <color name="launcher_background">#FFFFFF</color>
               <color name="colorPrimary">@android:color/transparent</color>
               <color name="colorPrimaryDark">#E3E31E</color>
               <color name="colorAccent">#FF4081</color>
            </resources>

Xaml tabs on page:

                    <Grid
                    BackgroundColor="black"
                    ColumnSpacing="0"
                    HorizontalOptions="FillAndExpand"
                    RowSpacing="0">
                    <Grid.RowDefinitions >
                        <RowDefinition Height="50" />
                        <RowDefinition Height="8" />
                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>
                        
                        <ColumnDefinition Width="150" />
                        <ColumnDefinition Width="150" />
                        <ColumnDefinition Width="150" />
                        <ColumnDefinition Width="150" />
                    </Grid.ColumnDefinitions>
                  //Closing tags below

MainActivity.cs:

 protected override void OnCreate(Bundle savedInstanceState)
    {
        AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo;
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;

        base.SetTheme(Resource.Style.MainTheme);

        base.OnCreate(savedInstanceState);

        global::Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
        global::Xamarin.Forms.FormsMaterial.Init(this, savedInstanceState);
        global::Xamarin.FormsMaps.Init(this, savedInstanceState);

        LoadApplication(new App(new AndroidInitializer()));
    }

I’ve gone through a number of stack overflow questions regarding tab layout and i can’t find any difference in my code compared to the accepted solutions.

Comments

Comment posted by clearyb123

This still doesn’t pick it up unfortunately. Am I missing some configuration file/ method?

Comment posted by Gobu CSG

Remove your theme and background as well… May be imapct

READ  [FIXED] android - Jetpack Compose: Backend Internal error when calling function with lambda from Coroutine
Powered by Inline Related Posts
Android Tags:android, android-tablayout

Post navigation

Previous Post: [FIXED] React-native android build fails due to missing files in the gradle cache?
Next Post: Can I use Google storage instead of iCloud?

Related Posts

[FIXED] Transfering iOS and Android App to different Developer Accounts – does Store Link for end users change? Android
[FIXED] android – How to stop playing a sound initiated in AlarmManager in Flutter Android
[FIXED] How to do Tab Host like Iphone in android? Android
[FIXED] crash – My app works fine on Android 9 but Keeps Crashing on Android 10 Android
[FIXED] android – Viewmodel preserving data after finishing activity Android
[FIXED] c# – Layout is not going to the bottom! It’s on the side Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Is the Nissan NV 2500 reliable?
  • Quel est le fromage qui porte le nom d’une commune de Côte d’Or et qui est produit en Haute-marne ?
  • Welches ist das beste Senioren Smartphone?
  • What is ISO benefit?
  • What do red bottom shoes represent?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme