Hollerweger
Hollerweger

Reputation: 1104

How to use Android Material Theme Design Attributes with Titanium (colored status bar, ...)

I want to use the Android theme attributes for my titanium android application:

https://developer.android.com/training/material/theme.html Android Theme Attributes

The application must be backward compatible to pre Lollipop (API 21) devices.

Upvotes: 1

Views: 1994

Answers (1)

Hollerweger
Hollerweger

Reputation: 1104

Titanium SDK 4.0.0RC+ now directly supports Theme.AppCompat with tinted action bar and status bar using theme attributes which is backward compatible.

First update your titanium CLI and SDK To 4.0.0RC+

npm install [email protected] (newest at the time of writing)

In your tiapp.xml make a reference to your theme definition:

<android xmlns:android="http://schemas.android.com/apk/res/android">
    <manifest>
        <application android:theme="@style/materialTheme"/>
    </manifest>
</android>

and change the SDK version:

<sdk-version>4.0.0.RC</sdk-version>

Define your theme attributes: platform/android/res/values/custom_theme.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="materialTheme" parent="@style/Theme.AppCompat">
    <item name="colorPrimary">#1565C0</item>
    <item name="colorPrimaryDark">#0D47A1</item>
    <item name="colorAccent">#FF80AB</item>
    <item name="colorControlNormal">#757575</item>
    <item name="colorControlActivated">#FF6E40</item>
    <item name="colorControlHighlight">#FF4081</item>
    <item name="colorSwitchThumbNormal">#BDBDBD</item>
    <item name="android:colorButtonNormal">#BDBDBD</item>
    <item name="android:colorEdgeEffect">#FF4081</item>
</style>
</resources>

Upvotes: 4

Related Questions