BaseCardView
class BaseCardView : FrameLayout
kotlin.Any | ||||
↳ | android.view.View | |||
↳ | android.view.ViewGroup | |||
↳ | android.widget.FrameLayout | |||
↳ | androidx.leanback.widget.BaseCardView |
ImageCardView |
A subclass of |
A card style layout that responds to certain state changes. It arranges its children in a vertical column, with different regions becoming visible at different times.
A BaseCardView will draw its children based on its type, the region visibilities of the child types, and the state of the widget. A child may be marked as belonging to one of three regions: main, info, or extra. The main region is always visible, while the info and extra regions can be set to display based on the activated or selected state of the View. The card states are set by calling setActivated
and setSelected
.
See BaseCardView.LayoutParams
for layout attributes.
Summary
Nested types |
---|
Per-child layout information associated with BaseCardView. |
Constants |
|
---|---|
const Int |
Indicates that a card region is visible when the card is activated. |
const Int |
Indicates that a card region is always visible. |
const Int |
Indicates that a card region is visible when the card is selected. |
const Int |
A Card type with 2 layout areas: A main area which is always visible, and an info area that fades in over the main area when it is visible. |
const Int |
A Card type with 2 layout areas: A main area which is always visible, and an info area that appears below the main area. |
const Int |
A Card type with 3 layout areas: A main area which is always visible; an info area which will appear below the main area, and an extra area that only appears after a short delay. |
const Int |
A simple card type with a single layout area. |
Public constructors |
---|
BaseCardView(context: Context!) |
BaseCardView(context: Context!, attrs: AttributeSet!) |
BaseCardView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int) |
Public functions |
|
---|---|
BaseCardView.LayoutParams! |
generateLayoutParams(attrs: AttributeSet!) |
Int |
Returns the type of this Card. |
Int |
This function is deprecated. Extra view's visibility is controlled by |
Int |
Returns the visibility of the info region of the card. |
Boolean |
Returns a boolean indicating if the selected animation will run immediately or be delayed the next time the card is Selected. |
Unit |
setActivated(activated: Boolean) Sets the Activated state of this Card. |
Unit |
setCardType(type: Int) Sets the type of this Card. |
Unit |
This function is deprecated. Extra view's visibility is controlled by |
Unit |
setInfoVisibility(visibility: Int) Sets the visibility of the info region of the card. |
Unit |
setSelected(selected: Boolean) Sets the Selected state of this Card. |
Unit |
setSelectedAnimationDelayed(delay: Boolean) Sets a flag indicating if the Selected animation (if the selected card type implements one) should run immediately after the card is selected, or if it should be delayed. |
Boolean |
|
String! |
toString() |
Protected functions |
|
---|---|
Boolean |
|
BaseCardView.LayoutParams! |
|
BaseCardView.LayoutParams! |
|
IntArray<Int>! |
onCreateDrawableState(extraSpace: Int) |
Unit |
|
Unit |
|
Unit |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Constants
CARD_REGION_VISIBLE_ACTIVATED
const val CARD_REGION_VISIBLE_ACTIVATED = 1: Int
Indicates that a card region is visible when the card is activated.
CARD_REGION_VISIBLE_ALWAYS
const val CARD_REGION_VISIBLE_ALWAYS = 0: Int
Indicates that a card region is always visible.
CARD_REGION_VISIBLE_SELECTED
const val CARD_REGION_VISIBLE_SELECTED = 2: Int
Indicates that a card region is visible when the card is selected.
CARD_TYPE_INFO_OVER
const val CARD_TYPE_INFO_OVER = 1: Int
A Card type with 2 layout areas: A main area which is always visible, and an info area that fades in over the main area when it is visible. The card height will not change.
See also | |
---|---|
getCardType |
CARD_TYPE_INFO_UNDER
const val CARD_TYPE_INFO_UNDER = 2: Int
A Card type with 2 layout areas: A main area which is always visible, and an info area that appears below the main area. When the info area is visible the total card height will change.
See also | |
---|---|
getCardType |
CARD_TYPE_INFO_UNDER_WITH_EXTRA
const val CARD_TYPE_INFO_UNDER_WITH_EXTRA = 3: Int
A Card type with 3 layout areas: A main area which is always visible; an info area which will appear below the main area, and an extra area that only appears after a short delay. The info area appears below the main area, causing the total card height to change. The extra area animates in at the bottom of the card, shifting up the info view without affecting the card height.
See also | |
---|---|
getCardType |
CARD_TYPE_MAIN_ONLY
const val CARD_TYPE_MAIN_ONLY = 0: Int
A simple card type with a single layout area. This card type does not change its layout or size as it transitions between Activated/Not-Activated or Selected/Unselected states.
See also | |
---|---|
getCardType |
Public constructors
BaseCardView
BaseCardView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)
Public functions
generateLayoutParams
fun generateLayoutParams(attrs: AttributeSet!): BaseCardView.LayoutParams!
getCardType
fun getCardType(): Int
Returns the type of this Card.
Returns | |
---|---|
Int |
The type of this card. |
getInfoVisibility
fun getInfoVisibility(): Int
Returns the visibility of the info region of the card.
isSelectedAnimationDelayed
fun isSelectedAnimationDelayed(): Boolean
Returns a boolean indicating if the selected animation will run immediately or be delayed the next time the card is Selected.
Returns | |
---|---|
Boolean |
true if this card is set to delay the selected animation the next time it is selected, or false if the selected animation will run immediately the next time the card is selected. |
setActivated
fun setActivated(activated: Boolean): Unit
Sets the Activated state of this Card. This can trigger changes in the card layout, resulting in views to become visible or hidden. A card is normally set to Activated state when its parent container (like a Row) receives focus, and then activates all of its children.
Parameters | |
---|---|
activated: Boolean |
True if the card is ACTIVE, or false if INACTIVE. |
See also | |
---|---|
isActivated |
setCardType
fun setCardType(type: Int): Unit
Sets the type of this Card.
Parameters | |
---|---|
type: Int |
The desired card type. |
funsetExtraVisibility(visibility: Int): Unit
Sets the visibility of the extra region of the card.
Parameters | |
---|---|
visibility: Int |
The region visibility to use for the extra region. Must be one of |
setInfoVisibility
fun setInfoVisibility(visibility: Int): Unit
Sets the visibility of the info region of the card.
Parameters | |
---|---|
visibility: Int |
The region visibility to use for the info region. Must be one of |
setSelected
fun setSelected(selected: Boolean): Unit
Sets the Selected state of this Card. This can trigger changes in the card layout, resulting in views to become visible or hidden. A card is normally set to Selected state when it receives input focus.
Parameters | |
---|---|
selected: Boolean |
True if the card is Selected, or false otherwise. |
See also | |
---|---|
isSelected |
setSelectedAnimationDelayed
fun setSelectedAnimationDelayed(delay: Boolean): Unit
Sets a flag indicating if the Selected animation (if the selected card type implements one) should run immediately after the card is selected, or if it should be delayed. The default behavior is to delay this animation. This is a one-shot override. If set to false, after the card is selected and the selected animation is triggered, this flag is automatically reset to true. This is useful when you want to change the default behavior, and have the selected animation run immediately. One such case could be when focus moves from one row to the other, when instead of delaying the selected animation until the user pauses on a card, it may be desirable to trigger the animation for that card immediately.
Parameters | |
---|---|
delay: Boolean |
True (default) if the selected animation should be delayed after the card is selected, or false if the animation should run immediately the next time the card is Selected. |
Protected functions
generateDefaultLayoutParams
protected fun generateDefaultLayoutParams(): BaseCardView.LayoutParams!
generateLayoutParams
protected fun generateLayoutParams(lp: ViewGroup.LayoutParams!): BaseCardView.LayoutParams!