public interface

TintableCompoundButton

 androidx.core.widget.TintableCompoundButton

Subclasses:

AppCompatCheckBox, AppCompatRadioButton

Gradle dependencies

compile group: 'androidx.core', name: 'core', version: '1.9.0-alpha04'

  • groupId: androidx.core
  • artifactId: core
  • version: 1.9.0-alpha04

Artifact androidx.core:core:1.9.0-alpha04 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.core:core com.android.support:support-compat

Androidx class mapping:

androidx.core.widget.TintableCompoundButton android.support.v4.widget.TintableCompoundButton

Overview

Interface which allows a android.widget.CompoundButton to receive tinting calls from CompoundButtonCompat when running on API v20 devices or lower.

Summary

Methods
public ColorStateListgetSupportButtonTintList()

Returns the tint applied to the button drawable

public PorterDuff.ModegetSupportButtonTintMode()

Returns the blending mode used to apply the tint to the button drawable

public voidsetSupportButtonTintList(ColorStateList tint)

Applies a tint to the button drawable.

public voidsetSupportButtonTintMode(PorterDuff.Mode tintMode)

Specifies the blending mode which should be used to apply the tint specified by TintableCompoundButton.setSupportButtonTintList(ColorStateList) to the button drawable.

Methods

public void setSupportButtonTintList(ColorStateList tint)

Applies a tint to the button drawable. Does not modify the current tint mode, which is by default.

Subsequent calls to setButtonDrawable(Drawable) should automatically mutate the drawable and apply the specified tint and tint mode.

Parameters:

tint: the tint to apply, may be null to clear tint

public ColorStateList getSupportButtonTintList()

Returns the tint applied to the button drawable

See also: TintableCompoundButton.setSupportButtonTintList(ColorStateList)

public void setSupportButtonTintMode(PorterDuff.Mode tintMode)

Specifies the blending mode which should be used to apply the tint specified by TintableCompoundButton.setSupportButtonTintList(ColorStateList) to the button drawable. The default mode is .

Parameters:

tintMode: the blending mode used to apply the tint, may be null to clear tint

See also: TintableCompoundButton.getSupportButtonTintMode(), DrawableCompat.setTintMode(Drawable, PorterDuff.Mode)

public PorterDuff.Mode getSupportButtonTintMode()

Returns the blending mode used to apply the tint to the button drawable

See also: TintableCompoundButton.setSupportButtonTintMode(PorterDuff.Mode)

Source

/*
 * Copyright (C) 2015 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.core.widget;

import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;

import androidx.annotation.Nullable;

/**
 * Interface which allows a {@link android.widget.CompoundButton} to receive tinting
 * calls from {@code CompoundButtonCompat} when running on API v20 devices or lower.
 */
/*
 * When used with androidx.resourceinspection.annotation.AppCompatShadowedAttributes, this
 * interface implies that AppCompat shadows the platform's button tint attributes.
 * See androidx.resourceinspection.processor for more details and a full mapping of attributes.
 */
public interface TintableCompoundButton {

    /**
     * Applies a tint to the button drawable. Does not modify the current tint
     * mode, which is {@link PorterDuff.Mode#SRC_IN} by default.
     * <p>
     * Subsequent calls to
     * {@link android.widget.CompoundButton#setButtonDrawable(Drawable) setButtonDrawable(Drawable)}
     * should automatically mutate the drawable and apply the specified tint and tint mode.
     *
     * @param tint the tint to apply, may be {@code null} to clear tint
     */
    void setSupportButtonTintList(@Nullable ColorStateList tint);

    /**
     * Returns the tint applied to the button drawable
     *
     * @see #setSupportButtonTintList(ColorStateList)
     */
    @Nullable
    ColorStateList getSupportButtonTintList();

    /**
     * Specifies the blending mode which should be used to apply the tint specified by
     * {@link #setSupportButtonTintList(ColorStateList)} to the button drawable. The
     * default mode is {@link PorterDuff.Mode#SRC_IN}.
     *
     * @param tintMode the blending mode used to apply the tint, may be
     *                 {@code null} to clear tint
     *
     * @see #getSupportButtonTintMode()
     * @see androidx.core.graphics.drawable.DrawableCompat#setTintMode(Drawable,
     * PorterDuff.Mode)
     */
    void setSupportButtonTintMode(@Nullable PorterDuff.Mode tintMode);

    /**
     * Returns the blending mode used to apply the tint to the button drawable
     *
     * @see #setSupportButtonTintMode(PorterDuff.Mode)
     */
    @Nullable
    PorterDuff.Mode getSupportButtonTintMode();
}