Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Android navigation and tabs title color #767

Closed
calebeaires opened this issue Sep 17, 2015 · 16 comments
Closed

Change Android navigation and tabs title color #767

calebeaires opened this issue Sep 17, 2015 · 16 comments

Comments

@calebeaires
Copy link

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>
@N3ll N3ll added this to the 1.5 (Under Review) milestone Sep 28, 2015
@bradmartin
Copy link
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.

@sitefinitysteve
Copy link
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.

@calebeaires
Copy link
Author

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

@bradmartin
Copy link
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.

@vakrilov vakrilov self-assigned this Oct 16, 2015
@sitefinitysteve
Copy link
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?

@vakrilov
Copy link
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.

@vakrilov vakrilov added ready for test TSC needs to test this and confirm against live production apps and automated test suites and removed in progress labels Oct 30, 2015
@vakrilov
Copy link
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.

@calebeaires
Copy link
Author

Amazing!

@alexrainman
Copy link

Yes :)

@bradmartin
Copy link
Contributor

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

@sitefinitysteve
Copy link
Contributor

Can't wait for 1.5 now!

@vchimev vchimev added done and removed ready for test TSC needs to test this and confirm against live production apps and automated test suites labels Nov 3, 2015
@vchimev vchimev closed this as completed Nov 3, 2015
@rclai
Copy link
Contributor

rclai commented Nov 3, 2015

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>

@vakrilov
Copy link
Contributor

vakrilov commented Nov 5, 2015

@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.

@rclai
Copy link
Contributor

rclai commented Nov 5, 2015

Thanks @vakrilov.

@dndeus
Copy link

dndeus commented Oct 13, 2016

Is it possible to change the background color per tab?

@lock
Copy link

lock bot commented Aug 29, 2019

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.

@lock lock bot locked and limited conversation to collaborators Aug 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants