Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

ColumnCardView

class ColumnCardView : CardView
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.FrameLayout
   ↳ androidx.cardview.widget.CardView
   ↳ androidx.car.widget.ColumnCardView

A CardView whose width can be specified by the number of columns that it will span.

The ColumnCardView works similarly to a regular CardView, except that its layout_width attribute is always ignored. Instead, its width is automatically calculated based on a specified columnSpan attribute. Alternatively, a user can call setColumnSpan(int). If no column span is given, the ColumnCardView will have a default span value that it uses.

<androidx.car.widget.ColumnCardView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      app:columnSpan="4" />
  

Summary

Public constructors

<init>(context: Context!)

<init>(context: Context!, attrs: AttributeSet!)

<init>(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

Public methods

Int

Returns the currently number of columns that this ColumnCardView spans.

Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

Unit
setColumnSpan(columnSpan: Int)

Sets the number of columns that this ColumnCardView will span.

Inherited functions

Public constructors

<init>

ColumnCardView(context: Context!)

<init>

ColumnCardView(context: Context!, attrs: AttributeSet!)

<init>

ColumnCardView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

Public methods

getColumnSpan

fun getColumnSpan(): Int

Returns the currently number of columns that this ColumnCardView spans.

Return
Int: The number of columns this ColumnCardView spans across.

onMeasure

fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int): Unit

setColumnSpan

fun setColumnSpan(columnSpan: Int): Unit

Sets the number of columns that this ColumnCardView will span. The given span is ignored if it is less than 0 or greater than the number of columns that fit on screen.

Parameters
columnSpan Int: The number of columns this ColumnCardView will span across.