Last active
November 5, 2015 15:57
-
-
Save vakrilov/3a6d293984c2c00c7256 to your computer and use it in GitHub Desktop.
ActionBar TabView colors - NS 1.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources xmlns:android="http://schemas.android.com/apk/res/android"> | |
<style name="AppThemeBase" parent="Theme.AppCompat.Light.NoActionBar"> | |
<!-- Set the text color used for ActionItems to white--> | |
<item name="actionMenuTextColor">#FFFFFF</item> | |
<!-- ... --> | |
</style> | |
<!-- ... --> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var color = require("color"); | |
var platform = require("platform"); | |
function pageLoaded(args) { | |
var page = args.object; | |
if (platform.device.os === platform.platformNames.android) { | |
// ------ ActionBar -------- | |
// Set ActionBar background color - done in XML/CSS | |
// Set ActionBar title color | |
var actionBarTextColor = new color.Color("white"); | |
page.actionBar._nativeView.setTitleTextColor(actionBarTextColor.android); | |
// ------ TabView -------- | |
var tabView = page.getViewById("tabView"); | |
var tabContainer = tabView._tabLayout; | |
// Set TabView background | |
var bgColor = new color.Color("blue"); | |
tabContainer.setBackgroundColor(bgColor.android); | |
// Set TabView selected-indicator color | |
var selectedIndicatorColor = new color.Color("yellow"); | |
tabContainer.setSelectedIndicatorColors([selectedIndicatorColor.android]); | |
// Set title color of TabView items - currently no easy way to do it. | |
} | |
} | |
exports.pageLoaded = pageLoaded; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded"> | |
<Page.actionBar> | |
<ActionBar title="My Title" style="background-color:blue; color:white"> | |
</ActionBar> | |
</Page.actionBar> | |
<TabView id="tabView"> | |
<TabView.items> | |
<TabViewItem title="First"> | |
<TabViewItem.view> | |
<Label text="First Tab" /> | |
</TabViewItem.view> | |
</TabViewItem> | |
<TabViewItem title="Second"> | |
<TabViewItem.view> | |
<Label text="Second Tab" /> | |
</TabViewItem.view> | |
</TabViewItem> | |
</TabView.items> | |
</TabView> | |
</Page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment