Skip to content

Change Android navigation and tabs title color #767

Closed

Description

@calebeaires

On this exemple, NativeScript dont change the text color from title bar, and title tabs bar.

    <Page.actionBar>
        <ActionBar title="Temas" style="background-color:blue;color:#fff">
        </ActionBar>
    </Page.actionBar>

Or

    <TabView>
        <TabView.items>
            <TabViewItem title="Questions" style="background-color:blue;color:#fff">
                <TabViewItem.view>
                    <GridLayout>
                        <ListView items="{{ items }}">
                            <ListView.itemTemplate>
                                <Label cssClass="cat" text="{{ question }}" textWrap="true" />
                            </ListView.itemTemplate>
                        </ListView>
                    </GridLayout>
                </TabViewItem.view>
            </TabViewItem>
   </TabView>

Activity

  1. added this to the milestone on Sep 28, 2015
  2. bradmartin commented on Sep 28, 2015

    @bradmartin
    Contributor

    @N3ll - do you think this will make it in the 1.5 release? If not, what is the native code to setBackgroundColor for the tabview? I'm a web dev and I have no idea how to figure out the abstraction to do this as someone pointed out it was possible via the native options on another the forums related to this.

  3. sitefinitysteve commented on Sep 28, 2015

    @sitefinitysteve
    Contributor

    This is pretty important for us as well... we can't match the app to the designers mockup, so we can't complete it to deploy at all.

  4. calebeaires commented on Oct 1, 2015

    @calebeaires
    Author

    All app samples on NativeScript shows how to change navigation style, but only on iOS.

  5. bradmartin commented on Oct 8, 2015

    @bradmartin
    Contributor

    Until there is an API or support for CSS to apply to the tabs, you can create a styles.xml file in your App_Resources/Android/values folder with the following and it should at least change the background of your TabView.

            <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
    <item name="windowNoTitle">true</item>
    <!--We will be using the toolbar so no need to show ActionBar-->
    <item name="windowActionBar">false</item>
    <!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette-->
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">@color/primaryColor</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">@color/primaryColorDark</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">@color/accentColor</item>
    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
    
    
    <item name="actionBarTabStyle">@color/primaryColor</item>
    <item name="actionBarTabBarStyle">@color/primaryColor</item>
    

    Also make sure you have those colors defined in a colors.xml file in the same folder. It's working for my app, I can't get the ActionBar to style but the TabView should work. Maybe someone more familiar with Android styling can help out.

  6. self-assigned this
    on Oct 16, 2015
  7. sitefinitysteve commented on Oct 18, 2015

    @sitefinitysteve
    Contributor

    @N3ll These things are just so key right now...can you guys maybe throw us a bone and do like a 1.4.4 or 1.4.5 that exposes\fixes actionbar\tab styling?

  8. vakrilov commented on Oct 19, 2015

    @vakrilov
    Contributor

    @sitefinitysteve @calebeaires
    Styling the ActionBar and TabBar colors is something we are currently working on for the 1.5 milestone. Currently - you should be able to set only the background-color of the action bar for Android.

    That said you can set some of the colors by accessing the native Android views and working on them directly. Check out this gist to see how to do that.

    Hope that helps for now.

  9. added
    ready for test
    and removed on Oct 30, 2015
  10. vakrilov commented on Oct 30, 2015

    @vakrilov
    Contributor

    After the #999 PR here are the styling options:
    ActionBar

    • color (CSS) - the title font color.
    • background-color (CSS) - background color of the ActionBar/NavigationBar.

    TabView

    • color (CSS) - the text color used for the tab items and the content(as color is inherited).
    • background-color(CSS) - background color of the content of the TavView.
    • tabsBackgroundColor (property of the TabView) - background color of the tab items.
    • selectedColor (property of the TabView) - accent color for the selected tab-item. This is the text color in iOS and the color of the selection indicator in Android.
  11. calebeaires commented on Oct 30, 2015

    @calebeaires
    Author

    Amazing!

  12. alexrainman commented on Oct 30, 2015

    @alexrainman

    Yes :)

  13. bradmartin commented on Oct 30, 2015

    @bradmartin
    Contributor

    What @calebeaires said. :) can't wait to try this.

  14. sitefinitysteve commented on Oct 30, 2015

    @sitefinitysteve
    Contributor

    Can't wait for 1.5 now!

  15. added and removed
    ready for test
    on Nov 3, 2015
  16. rclai commented on Nov 3, 2015

    @rclai
    Contributor

    Thanks for that snippet.

    Also how do you change the color of the ellipses when you have these:

    <ActionBar.actionItems>
            <ActionItem text="Edit Room" android.position="popup" />
            <ActionItem text="Add Device" android.position="popup" />
            <ActionItem text="Add Room" android.position="popup" />
            <ActionItem text="Log Out" tap="logOut" android.position="popup" />
    </ActionBar.actionItems>
  17. vakrilov commented on Nov 5, 2015

    @vakrilov
    Contributor

    @rclai
    You can change the color of the action items by modifying the styles.xml file with the android themes (located at [project]\App_Resource\Android\values).
    I have updated the gist to include that.

  18. rclai commented on Nov 5, 2015

    @rclai
    Contributor

    Thanks @vakrilov.

  19. dndeus commented on Oct 13, 2016

    @dndeus

    Is it possible to change the background color per tab?

  20. lock commented on Aug 29, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  21. locked and limited conversation to collaborators on Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions