テーマを追加することで、Digits の見栄えをあなたのアプリのようにすることができます。既定では、 Digits機能では標準のAndroid lightテーマを使って描写しますが、 独自のテーマを設定することでこれをカスタマイズできます。
Theming DigitsYou can make Digits look and feel like your app by adding a theme. By default, Digits will render using the standard Android light theme, but you can customize this by setting your own theme. |
プログラムコード上からDigits 機能を開始している場合、startSignUpに追加のパラメータとしてテーマを渡すことで、テーマを設定できます。
//テーマ設定の例
Digits.authenticate(callback,
android.R.style.Theme_Material);
DigitsAuthButtonを使用している場合、setAuthTheme メソッドを実行することでテーマを設定できます。
//Example of setting theme on DigitsAuthButton
DigitsAuthButton digitsAuthButton =
(DigitsAuthButton) findViewById(R.id.auth_button);
digitsAuthButton.setCallback(callback);
digitsAuthButton
.setAuthTheme(android.R.style.Theme_Material);
上記の手順はどちらも、Material Darkテーマを使ってユーザー認証フローを開始しています。
Setting the themeIf you are starting Digits programmatically, you can set the theme by supplying the theme as an additional parameter to
//Example of setting theme
Digits.authenticate(callback,
android.R.style.Theme_Material);
If you’re using the
//Example of setting theme on DigitsAuthButton
DigitsAuthButton digitsAuthButton =
(DigitsAuthButton) findViewById(R.id.auth_button);
digitsAuthButton.setCallback(callback);
digitsAuthButton
.setAuthTheme(android.R.style.Theme_Material);
Either method will start the user authentication flow using the Material Dark theme.
|
Digits機能のテーマには以下の属性を使用できます。
| 属性 | 効果 |
| android:textColorPrimary | タイトルの色 |
| android:textColorSecondary | 説明文と サービス規約文 の色 |
| android:windowBackground | 背景色 |
| android:textColorLink | テキストリンクの色 |
| android:colorAccent (API 21+) | イメージカラー、ボタンの色、ウィジットの色 |
| colorAccent (AppCompat v7) | イメージカラー、ボタンの色、ウィジットの色 |
| dgts__accentColor | イメージカラー、ボタンの色 |
Customizing the themeThe following attributes may be used to theme Digits.
|
Material テーマの例:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomDigitsTheme"
parent="android:Theme.Material.Light">
<item name="android:textColorPrimary">
@android:color/black</item>
<item name="android:textColorSecondary">
@android:color/darker_gray</item>
<item name="android:windowBackground">
@android:color/white</item>
<item name="android:textColorLink">#ff398622</item>
<item name="android:colorAccent">#ff398622</item>
</style>
</resources>
プロジェクトに appcompat-v7 がインクルードされてTheme.AppCompatテーマが設定されている場合、Digits機能は自動的にActionBarActivityを継承したアクティビティを使用します。
ExamplesSample Material theme:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomDigitsTheme"
parent="android:Theme.Material.Light">
<item name="android:textColorPrimary">
@android:color/black</item>
<item name="android:textColorSecondary">
@android:color/darker_gray</item>
<item name="android:windowBackground">
@android:color/white</item>
<item name="android:textColorLink">#ff398622</item>
<item name="android:colorAccent">#ff398622</item>
</style>
</resources>
If |
AppCompat テーマの例:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomDigitsTheme"
parent="Theme.AppCompat.Light">
<item name="android:textColorPrimary">
@android:color/black</item>
<item name="android:textColorSecondary">
@android:color/darker_gray</item>
<item name="android:windowBackground">
@android:color/white</item>
<item name="android:textColorLink">#ff398622</item>
<item name="colorAccent">#ff398622</item>
</style>
</resources>
注意:
イメージカラーとボタンの色は、Material テーマもしくはAppCompatテーマ内にある、
android:colorAccent属性やcolorAccent属性によって設定されます。 この動作はdgts__accentColor属性を使って上書きできます。
|
Sample AppCompat theme:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomDigitsTheme"
parent="Theme.AppCompat.Light">
<item name="android:textColorPrimary">
@android:color/black</item>
<item name="android:textColorSecondary">
@android:color/darker_gray</item>
<item name="android:windowBackground">
@android:color/white</item>
<item name="android:textColorLink">#ff398622</item>
<item name="colorAccent">#ff398622</item>
</style>
</resources>
|
Holo テーマの例:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomDigitsTheme"
parent="android:Theme.Holo.Light">
<item name="android:textColorPrimary">
@android:color/black</item>
<item name="android:textColorSecondary">
@android:color/darker_gray</item>
<item name="android:windowBackground">
@android:color/white</item>
<item name="android:textColorLink">#ff398622</item>
<item name="dgts__accentColor">#ff398622</item>
</style>
</resources>
注意:
android:editTextStyle 属性を設定することで、EditText にもテーマを設定できます。
|
Sample Holo theme:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomDigitsTheme"
parent="android:Theme.Holo.Light">
<item name="android:textColorPrimary">
@android:color/black</item>
<item name="android:textColorSecondary">
@android:color/darker_gray</item>
<item name="android:windowBackground">
@android:color/white</item>
<item name="android:textColorLink">#ff398622</item>
<item name="dgts__accentColor">#ff398622</item>
</style>
</resources>
|