public class

Colors

extends java.lang.Object

 java.lang.Object

↳androidx.wear.protolayout.material.Colors

Gradle dependencies

compile group: 'androidx.wear.protolayout', name: 'protolayout-material', version: '1.2.0'

  • groupId: androidx.wear.protolayout
  • artifactId: protolayout-material
  • version: 1.2.0

Artifact androidx.wear.protolayout:protolayout-material:1.2.0 it located at Google repository (https://maven.google.com/)

Overview

Represent the container for default color scheme in your Tile, that can be used to create color objects for all Material components.

See Colors.DEFAULT for default color scheme.

Summary

Fields
public static final ColorsDEFAULT

The default color scheme to be used in ProtoLayout Material components.

public static final intON_PRIMARY

The default color used on primary elements (i.e.

public static final intON_SURFACE

The default color used on secondary elements (i.e.

public static final intPRIMARY

The default color used for primary elements (i.e.

public static final intSURFACE

The default color used for secondary elements (i.e.

Constructors
publicColors(int primary, int onPrimary, int surface, int onSurface)

Constructor for Colors object.

Methods
public intgetOnPrimary()

The onPrimary color to be used on components.

public intgetOnSurface()

The onSurface color to be used on components.

public intgetPrimary()

The primary color to be used on components.

public intgetSurface()

The surface color to be used on components.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public static final int PRIMARY

The default color used for primary elements (i.e. background color).

public static final int ON_PRIMARY

The default color used on primary elements (i.e. content color).

public static final int SURFACE

The default color used for secondary elements (i.e. background color).

public static final int ON_SURFACE

The default color used on secondary elements (i.e. content color).

public static final Colors DEFAULT

The default color scheme to be used in ProtoLayout Material components.

Constructors

public Colors(int primary, int onPrimary, int surface, int onSurface)

Constructor for Colors object.

Parameters:

primary: The background color to be used for primary components. Should be in ARGB format.
onPrimary: The content color or tint color to be used for primary components. Should be in ARGB format.
surface: The background color to be used for secondary components. Should be in ARGB format.
onSurface: The content color or tint color to be used for secondary components. Should be in ARGB format.

Methods

public int getPrimary()

The primary color to be used on components.

public int getOnPrimary()

The onPrimary color to be used on components.

public int getSurface()

The surface color to be used on components.

public int getOnSurface()

The onSurface color to be used on components.

Source

/*
 * Copyright 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.wear.protolayout.material;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;

/**
 * Represent the container for default color scheme in your Tile, that can be used to create color
 * objects for all Material components.
 *
 * <p>See {@link #DEFAULT} for default color scheme.
 */
public class Colors {

    /** The default color used for primary elements (i.e. background color). */
    @RestrictTo(Scope.LIBRARY_GROUP)
    @ColorInt
    public static final int PRIMARY = 0xFFAECBFA;

    /** The default color used on primary elements (i.e. content color). */
    @RestrictTo(Scope.LIBRARY_GROUP)
    @ColorInt
    public static final int ON_PRIMARY = 0xFF303133;

    /** The default color used for secondary elements (i.e. background color). */
    @RestrictTo(Scope.LIBRARY_GROUP)
    @ColorInt
    public static final int SURFACE = 0xFF303133;

    /** The default color used on secondary elements (i.e. content color). */
    @RestrictTo(Scope.LIBRARY_GROUP)
    @ColorInt
    public static final int ON_SURFACE = 0xFFFFFFFF;

    /** The default color scheme to be used in ProtoLayout Material components. */
    @NonNull
    public static final Colors DEFAULT = new Colors(PRIMARY, ON_PRIMARY, SURFACE, ON_SURFACE);

    @ColorInt private final int mPrimary;
    @ColorInt private final int mOnPrimary;
    @ColorInt private final int mSurface;
    @ColorInt private final int mOnSurface;

    /**
     * Constructor for {@link Colors} object.
     *
     * @param primary The background color to be used for primary components. Should be in ARGB
     *     format.
     * @param onPrimary The content color or tint color to be used for primary components. Should be
     *     in ARGB format.
     * @param surface The background color to be used for secondary components. Should be in ARGB
     *     format.
     * @param onSurface The content color or tint color to be used for secondary components. Should
     *     be in ARGB format.
     */
    public Colors(
            @ColorInt int primary,
            @ColorInt int onPrimary,
            @ColorInt int surface,
            @ColorInt int onSurface) {
        this.mPrimary = primary;
        this.mOnPrimary = onPrimary;
        this.mSurface = surface;
        this.mOnSurface = onSurface;
    }

    /** The primary color to be used on components. */
    @ColorInt
    public int getPrimary() {
        return mPrimary;
    }

    /** The onPrimary color to be used on components. */
    @ColorInt
    public int getOnPrimary() {
        return mOnPrimary;
    }

    /** The surface color to be used on components. */
    @ColorInt
    public int getSurface() {
        return mSurface;
    }

    /** The onSurface color to be used on components. */
    @ColorInt
    public int getOnSurface() {
        return mOnSurface;
    }
}