public class

ButtonColors

extends java.lang.Object

 java.lang.Object

↳androidx.wear.tiles.material.ButtonColors

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 button Tiles component.

See ButtonDefaults.PRIMARY_BUTTON_COLORS for the default colors used in a primary styled Button. See ButtonDefaults.SECONDARY_BUTTON_COLORS for the default colors used in a secondary styled Button.

Summary

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

Constructor for ButtonColors object.

publicButtonColors(int backgroundColor, int contentColor)

Constructor for ButtonColors object.

Methods
public ColorBuilders.ColorPropgetBackgroundColor()

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

public ColorBuilders.ColorPropgetContentColor()

The content or tint color to be used on a button Tiles components.

public static ButtonColorsprimaryButtonColors(Colors colors)

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

public static ButtonColorssecondaryButtonColors(Colors colors)

Returns a ButtonColors 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 ButtonColors(int backgroundColor, int contentColor)

Constructor for ButtonColors object.

Parameters:

backgroundColor: The background color to be used for a button Tiles component. Should be in ARGB format.
contentColor: The content color or tint color to be used for a button Tiles component. Should be in ARGB format.

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

Constructor for ButtonColors object.

Parameters:

backgroundColor: The background color to be used for a button.
contentColor: The content color or tint color to be used for a button.

Methods

public static ButtonColors primaryButtonColors(Colors colors)

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

public static ButtonColors secondaryButtonColors(Colors colors)

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

public ColorBuilders.ColorProp getBackgroundColor()

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

public ColorBuilders.ColorProp getContentColor()

The content or tint color to be used on a button 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 button Tiles component.
 *
 * <p>See {@link ButtonDefaults#PRIMARY_BUTTON_COLORS} for the default colors used in a primary
 * styled {@link Button}. See {@link ButtonDefaults#SECONDARY_BUTTON_COLORS} for the default colors
 * used in a secondary styled {@link Button}.
 */
public class ButtonColors {
    @NonNull private final ColorProp mBackgroundColor;
    @NonNull private final ColorProp mContentColor;

    /**
     * Constructor for {@link ButtonColors} object.
     *
     * @param backgroundColor The background color to be used for a button Tiles component. Should
     *     be in ARGB format.
     * @param contentColor The content color or tint color to be used for a button Tiles component.
     *     Should be in ARGB format.
     */
    public ButtonColors(@ColorInt int backgroundColor, @ColorInt int contentColor) {
        mBackgroundColor = argb(backgroundColor);
        mContentColor = argb(contentColor);
    }

    /**
     * Constructor for {@link ButtonColors} object.
     *
     * @param backgroundColor The background color to be used for a button.
     * @param contentColor The content color or tint color to be used for a button.
     */
    public ButtonColors(@NonNull ColorProp backgroundColor, @NonNull ColorProp contentColor) {
        mBackgroundColor = backgroundColor;
        mContentColor = contentColor;
    }

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

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

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

    /** The content or tint color to be used on a button Tiles components. */
    @NonNull
    public ColorProp getContentColor() {
        return mContentColor;
    }
}