public class

CardViewBindingAdapter

extends java.lang.Object

 java.lang.Object

↳androidx.databinding.adapters.CardViewBindingAdapter

Gradle dependencies

compile group: 'androidx.databinding', name: 'databinding-adapters', version: '7.4.0-alpha02'

  • groupId: androidx.databinding
  • artifactId: databinding-adapters
  • version: 7.4.0-alpha02

Artifact androidx.databinding:databinding-adapters:7.4.0-alpha02 it located at Google repository (https://maven.google.com/)

Androidx class mapping:

androidx.databinding.adapters.CardViewBindingAdapter android.databinding.adapters.CardViewBindingAdapter

Summary

Constructors
publicCardViewBindingAdapter()

Methods
public static voidsetContentPadding(CardView view, int padding)

public static voidsetContentPaddingBottom(CardView view, int bottom)

public static voidsetContentPaddingLeft(CardView view, int left)

public static voidsetContentPaddingRight(CardView view, int right)

public static voidsetContentPaddingTop(CardView view, int top)

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

Constructors

public CardViewBindingAdapter()

Methods

public static void setContentPadding(CardView view, int padding)

public static void setContentPaddingLeft(CardView view, int left)

public static void setContentPaddingTop(CardView view, int top)

public static void setContentPaddingRight(CardView view, int right)

public static void setContentPaddingBottom(CardView view, int bottom)

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.databinding.adapters;

import androidx.databinding.BindingAdapter;
import androidx.databinding.BindingMethod;
import androidx.databinding.BindingMethods;
import androidx.annotation.RestrictTo;
import androidx.cardview.widget.CardView;

/**
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY)
@BindingMethods({
        @BindingMethod(type = androidx.cardview.widget.CardView.class, attribute = "cardCornerRadius", method = "setRadius"),
        @BindingMethod(type = androidx.cardview.widget.CardView.class, attribute = "cardMaxElevation", method = "setMaxCardElevation"),
        @BindingMethod(type = androidx.cardview.widget.CardView.class, attribute = "cardPreventCornerOverlap", method = "setPreventCornerOverlap"),
        @BindingMethod(type = androidx.cardview.widget.CardView.class, attribute = "cardUseCompatPadding", method = "setUseCompatPadding"),
})
public class CardViewBindingAdapter {

    @BindingAdapter("contentPadding")
    public static void setContentPadding(CardView view, int padding) {
        view.setContentPadding(padding, padding, padding, padding);
    }

    @BindingAdapter("contentPaddingLeft")
    public static void setContentPaddingLeft(CardView view, int left) {
        int top = view.getContentPaddingTop();
        int right = view.getContentPaddingRight();
        int bottom = view.getContentPaddingBottom();
        view.setContentPadding(left, top, right, bottom);
    }

    @BindingAdapter("contentPaddingTop")
    public static void setContentPaddingTop(CardView view, int top) {
        int left = view.getContentPaddingLeft();
        int right = view.getContentPaddingRight();
        int bottom = view.getContentPaddingBottom();
        view.setContentPadding(left, top, right, bottom);
    }

    @BindingAdapter("contentPaddingRight")
    public static void setContentPaddingRight(CardView view, int right) {
        int left = view.getContentPaddingLeft();
        int top = view.getContentPaddingTop();
        int bottom = view.getContentPaddingBottom();
        view.setContentPadding(left, top, right, bottom);
    }

    @BindingAdapter("contentPaddingBottom")
    public static void setContentPaddingBottom(CardView view, int bottom) {
        int left = view.getContentPaddingLeft();
        int top = view.getContentPaddingTop();
        int right = view.getContentPaddingRight();
        view.setContentPadding(left, top, right, bottom);
    }
}