public class

ButtonDefaults

extends java.lang.Object

 java.lang.Object

↳androidx.wear.protolayout.material.ButtonDefaults

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

Contains the default values used by Button.

Summary

Fields
public static final DimensionBuilders.DpPropDEFAULT_SIZE

The default size for standard Button.

public static final DimensionBuilders.DpPropEXTRA_LARGE_SIZE

The recommended size for extra large Button.

public static final DimensionBuilders.DpPropLARGE_SIZE

The recommended size for large Button.

public static final ButtonColorsPRIMARY_COLORS

The recommended colors for a primary Button.

public static final ButtonColorsSECONDARY_COLORS

The recommended colors for a secondary Button.

Methods
public static DimensionBuilders.DpProprecommendedIconSize(DimensionBuilders.DpProp buttonSize)

Returns the recommended icon size for the given size of Button.

public static DimensionBuilders.DpProprecommendedIconSize(float buttonSize)

Returns the recommended icon size for the given size of Button.

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

Fields

public static final DimensionBuilders.DpProp DEFAULT_SIZE

The default size for standard Button.

public static final DimensionBuilders.DpProp LARGE_SIZE

The recommended size for large Button.

public static final DimensionBuilders.DpProp EXTRA_LARGE_SIZE

The recommended size for extra large Button.

public static final ButtonColors PRIMARY_COLORS

The recommended colors for a primary Button.

public static final ButtonColors SECONDARY_COLORS

The recommended colors for a secondary Button.

Methods

public static DimensionBuilders.DpProp recommendedIconSize(DimensionBuilders.DpProp buttonSize)

Returns the recommended icon size for the given size of Button.

public static DimensionBuilders.DpProp recommendedIconSize(float buttonSize)

Returns the recommended icon size for the given size of Button.

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 static androidx.annotation.Dimension.DP;
import static androidx.wear.protolayout.DimensionBuilders.dp;

import androidx.annotation.Dimension;
import androidx.annotation.NonNull;
import androidx.wear.protolayout.DimensionBuilders.DpProp;

/** Contains the default values used by {@link Button}. */
public class ButtonDefaults {
    private ButtonDefaults() {}

    /** The default size for standard {@link Button}. */
    @NonNull public static final DpProp DEFAULT_SIZE = dp(52);

    /** The recommended size for large {@link Button}. */
    @NonNull public static final DpProp LARGE_SIZE = dp(60);

    /** The recommended size for extra large {@link Button}. */
    @NonNull public static final DpProp EXTRA_LARGE_SIZE = dp(88);

    /** Returns the recommended icon size for the given size of {@link Button}. */
    @NonNull
    public static DpProp recommendedIconSize(@NonNull DpProp buttonSize) {
        return recommendedIconSize(buttonSize.getValue());
    }

    /** Returns the recommended icon size for the given size of {@link Button}. */
    @NonNull
    public static DpProp recommendedIconSize(@Dimension(unit = DP) float buttonSize) {
        return dp(buttonSize / 2);
    }

    /** The recommended colors for a primary {@link Button}. */
    @NonNull
    public static final ButtonColors PRIMARY_COLORS =
            ButtonColors.primaryButtonColors(Colors.DEFAULT);

    /** The recommended colors for a secondary {@link Button}. */
    @NonNull
    public static final ButtonColors SECONDARY_COLORS =
            ButtonColors.secondaryButtonColors(Colors.DEFAULT);
}