public class

ChipColors

extends java.lang.Object

 java.lang.Object

↳androidx.wear.tiles.material.ChipColors

Gradle dependencies

compile group: 'androidx.wear.tiles', name: 'tiles-material', version: '1.1.0-alpha07'

  • groupId: androidx.wear.tiles
  • artifactId: tiles-material
  • version: 1.1.0-alpha07

Artifact androidx.wear.tiles:tiles-material:1.1.0-alpha07 it located at Google repository (https://maven.google.com/)

Overview

Represents the background and content colors used in a chip Tiles component.

See ChipDefaults.PRIMARY_COLORS for the default colors used in a primary styled Chip. See ChipDefaults.SECONDARY_COLORS for the default colors used in a secondary styled Chip.

Summary

Constructors
publicChipColors(ColorBuilders.ColorProp backgroundColor, ColorBuilders.ColorProp contentColor)

Constructor for the ChipColors object.

publicChipColors(ColorBuilders.ColorProp backgroundColor, ColorBuilders.ColorProp iconColor, ColorBuilders.ColorProp contentColor, ColorBuilders.ColorProp secondaryContentColor)

Constructor for the ChipColors object.

publicChipColors(int backgroundColor, int contentColor)

Constructor for the ChipColors object.

publicChipColors(int backgroundColor, int iconColor, int contentColor, int secondaryContentColor)

Constructor for the ChipColors object.

Methods
public ColorBuilders.ColorPropgetBackgroundColor()

The background color to be used on a chip Tiles components.

public ColorBuilders.ColorPropgetContentColor()

The main text color to be used on a chip Tiles components.

public ColorBuilders.ColorPropgetIconColor()

The icon color to be used on a chip Tiles components.

public ColorBuilders.ColorPropgetSecondaryContentColor()

The label text color to be used on a chip Tiles components.

public static ChipColorsprimaryChipColors(Colors colors)

Returns a ChipColors object, using the current Primary colors from the given Colors.

public static ChipColorssecondaryChipColors(Colors colors)

Returns a ChipColors object, using the current Surface colors from the given Colors.

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

Constructors

public ChipColors(int backgroundColor, int iconColor, int contentColor, int secondaryContentColor)

Constructor for the ChipColors object.

Parameters:

backgroundColor: The background color to be used for a chip Tiles component. Should be in ARGB format.
iconColor: The color to be used for an icon in a chip Tiles component. Should be in ARGB format.
contentColor: The text color to be used for a main text in a chip Tiles component. Should be in ARGB format.
secondaryContentColor: The text color to be used for a label text in a chip Tiles component. Should be in ARGB format.

public ChipColors(int backgroundColor, int contentColor)

Constructor for the ChipColors object.

Parameters:

backgroundColor: The background color to be used for a chip Tiles component. Should be in ARGB format.
contentColor: The content color to be used for all items inside a chip Tiles component. Should be in ARGB format.

public ChipColors(ColorBuilders.ColorProp backgroundColor, ColorBuilders.ColorProp iconColor, ColorBuilders.ColorProp contentColor, ColorBuilders.ColorProp secondaryContentColor)

Constructor for the ChipColors object.

Parameters:

backgroundColor: The background color to be used for a chip Tiles component.
iconColor: The color to be used for an icon in a chip Tiles component.
contentColor: The text color to be used for a main text in a chip Tiles component.
secondaryContentColor: The text color to be used for a label text in a chip Tiles component.

public ChipColors(ColorBuilders.ColorProp backgroundColor, ColorBuilders.ColorProp contentColor)

Constructor for the ChipColors object.

Parameters:

backgroundColor: The background color to be used for a chip Tiles component.
contentColor: The content color to be used for all items inside a chip Tiles component.

Methods

public static ChipColors primaryChipColors(Colors colors)

Returns a ChipColors object, using the current Primary colors from the given Colors.

public static ChipColors secondaryChipColors(Colors colors)

Returns a ChipColors object, using the current Surface colors from the given Colors.

public ColorBuilders.ColorProp getBackgroundColor()

The background color to be used on a chip Tiles components.

public ColorBuilders.ColorProp getIconColor()

The icon color to be used on a chip Tiles components.

public ColorBuilders.ColorProp getContentColor()

The main text color to be used on a chip Tiles components.

public ColorBuilders.ColorProp getSecondaryContentColor()

The label text color to be used on a chip Tiles 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.tiles.material;

import static androidx.wear.tiles.ColorBuilders.argb;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.wear.tiles.ColorBuilders.ColorProp;

/**
 * Represents the background and content colors used in a chip Tiles component.
 *
 * <p>See {@link ChipDefaults#PRIMARY_COLORS} for the default colors used in a primary styled {@link
 * Chip}. See {@link ChipDefaults#SECONDARY_COLORS} for the default colors used in a secondary
 * styled {@link Chip}.
 */
public class ChipColors {
    @NonNull private final ColorProp mBackgroundColor;
    @NonNull private final ColorProp mIconColor;
    @NonNull private final ColorProp mContentColor;
    @NonNull private final ColorProp mSecondaryContentColor;

    /**
     * Constructor for the {@link ChipColors} object.
     *
     * @param backgroundColor The background color to be used for a chip Tiles component. Should be
     *     in ARGB format.
     * @param iconColor The color to be used for an icon in a chip Tiles component. Should be in
     *     ARGB format.
     * @param contentColor The text color to be used for a main text in a chip Tiles component.
     *     Should be in ARGB format.
     * @param secondaryContentColor The text color to be used for a label text in a chip Tiles
     *     component. Should be in ARGB format.
     */
    public ChipColors(
            @ColorInt int backgroundColor,
            @ColorInt int iconColor,
            @ColorInt int contentColor,
            @ColorInt int secondaryContentColor) {
        mBackgroundColor = argb(backgroundColor);
        mIconColor = argb(iconColor);
        mContentColor = argb(contentColor);
        mSecondaryContentColor = argb(secondaryContentColor);
    }

    /**
     * Constructor for the {@link ChipColors} object.
     *
     * @param backgroundColor The background color to be used for a chip Tiles component. Should be
     *     in ARGB format.
     * @param contentColor The content color to be used for all items inside a chip Tiles component.
     *     Should be in ARGB format.
     */
    public ChipColors(@ColorInt int backgroundColor, @ColorInt int contentColor) {
        mBackgroundColor = argb(backgroundColor);
        mIconColor = argb(contentColor);
        mContentColor = argb(contentColor);
        mSecondaryContentColor = argb(contentColor);
    }

    /**
     * Constructor for the {@link ChipColors} object.
     *
     * @param backgroundColor The background color to be used for a chip Tiles component.
     * @param iconColor The color to be used for an icon in a chip Tiles component.
     * @param contentColor The text color to be used for a main text in a chip Tiles component.
     * @param secondaryContentColor The text color to be used for a label text in a chip Tiles
     *     component.
     */
    public ChipColors(
            @NonNull ColorProp backgroundColor,
            @NonNull ColorProp iconColor,
            @NonNull ColorProp contentColor,
            @NonNull ColorProp secondaryContentColor) {
        mBackgroundColor = backgroundColor;
        mIconColor = iconColor;
        mContentColor = contentColor;
        mSecondaryContentColor = secondaryContentColor;
    }

    /**
     * Constructor for the {@link ChipColors} object.
     *
     * @param backgroundColor The background color to be used for a chip Tiles component.
     * @param contentColor The content color to be used for all items inside a chip Tiles component.
     */
    public ChipColors(@NonNull ColorProp backgroundColor, @NonNull ColorProp contentColor) {
        mBackgroundColor = backgroundColor;
        mIconColor = contentColor;
        mContentColor = contentColor;
        mSecondaryContentColor = contentColor;
    }

    /**
     * Returns a {@link ChipColors} object, using the current Primary colors from the given {@link
     * Colors}.
     */
    @NonNull
    public static ChipColors primaryChipColors(@NonNull Colors colors) {
        return new ChipColors(colors.getPrimary(), colors.getOnPrimary());
    }

    /**
     * Returns a {@link ChipColors} object, using the current Surface colors from the given {@link
     * Colors}.
     */
    @NonNull
    public static ChipColors secondaryChipColors(@NonNull Colors colors) {
        return new ChipColors(colors.getSurface(), colors.getOnSurface());
    }

    /** The background color to be used on a chip Tiles components. */
    @NonNull
    public ColorProp getBackgroundColor() {
        return mBackgroundColor;
    }

    /** The icon color to be used on a chip Tiles components. */
    @NonNull
    public ColorProp getIconColor() {
        return mIconColor;
    }

    /** The main text color to be used on a chip Tiles components. */
    @NonNull
    public ColorProp getContentColor() {
        return mContentColor;
    }

    /** The label text color to be used on a chip Tiles components. */
    @NonNull
    public ColorProp getSecondaryContentColor() {
        return mSecondaryContentColor;
    }
}