belongs to Maven artifact com.android.support:leanback-v17:28.0.0-alpha1
ImageCardView
public
class
ImageCardView
extends BaseCardView
java.lang.Object | |||||
↳ | android.view.View | ||||
↳ | android.view.ViewGroup | ||||
↳ | android.widget.FrameLayout | ||||
↳ | android.support.v17.leanback.widget.BaseCardView | ||||
↳ | android.support.v17.leanback.widget.ImageCardView |
A subclass of BaseCardView
with an ImageView
as its main region. The
ImageCardView
is highly customizable and can be used for various use-cases by adjusting
the ImageViewCard's type to any combination of Title, Content, Badge or ImageOnly.
Styling
There are two different ways to style the ImageCardView.No matter what way you use, all your styles applied to an ImageCardView have to extend the style
Widget_Leanback_ImageCardViewStyle
.
Example:
<style name="CustomImageCardViewStyle" parent="Widget.Leanback.ImageCardViewStyle">
<item name="cardBackground">#F0F</item>
<item name="lbImageCardViewType">Title|Content</item>
</style>
<style name="CustomImageCardTheme" parent="Theme.Leanback">
<item name="imageCardViewStyle">@style/CustomImageCardViewStyle</item>
<item name="imageCardViewInfoAreaStyle">@style/ImageCardViewColoredInfoArea</item>
<item name="imageCardViewTitleStyle">@style/ImageCardViewColoredTitle</item>
</style>
The first possibility is to set custom Styles in the Leanback Theme's attributes
imageCardViewStyle
, imageCardViewTitleStyle
etc. The styles set here,
is the default style for all ImageCardViews.
The second possibility allows you to style a particular ImageCardView. This is useful if you
want to create multiple types of cards. E.g. you might want to display a card with only a title
and another one with title and content. Thus you need to define two different
ImageCardViewStyles
and two different themes and apply them to the ImageCardViews.
You can do this by using a the ImageCardView(Context)
constructor and passing a
ContextThemeWrapper with the custom ImageCardView theme id.
Example (using constructor):
new ImageCardView(new ContextThemeWrapper(context, R.style.CustomImageCardTheme));
You can style all ImageCardView's components such as the title, content, badge, infoArea and the image itself by extending the corresponding style and overriding the specific attribute in your custom ImageCardView theme.
Components
The ImageCardView contains three components which can be combined in any combination:- Title: The card's title
- Content: A short description
- Badge: An icon which can be displayed on the right or left side of the card.
lbImageCardViewType
attribute of your custom ImageCardViewStyle
.
You can combine the following values:
Title, Content, IconOnRight, IconOnLeft, ImageOnly
.
Examples:
<style name="CustomImageCardViewStyle" parent="Widget.Leanback.ImageCardViewStyle">
...
<item name="lbImageCardViewType">Title|Content|IconOnLeft</item>
...
</style>
<style name="CustomImageCardViewStyle" parent="Widget.Leanback.ImageCardViewStyle">
...
<item name="lbImageCardViewType">ImageOnly</item>
...
</style>
Summary
XML attributes | |
---|---|
LeanbackTheme_imageCardViewBadgeStyle |
|
LeanbackTheme_imageCardViewContentStyle |
|
LeanbackTheme_imageCardViewImageStyle |
|
LeanbackTheme_imageCardViewInfoAreaStyle |
|
LeanbackTheme_imageCardViewStyle |
|
LeanbackTheme_imageCardViewTitleStyle |
|
lbImageCardView_lbImageCardViewType |
Constants | |
---|---|
int |
CARD_TYPE_FLAG_CONTENT
|
int |
CARD_TYPE_FLAG_ICON_LEFT
|
int |
CARD_TYPE_FLAG_ICON_RIGHT
|
int |
CARD_TYPE_FLAG_IMAGE_ONLY
|
int |
CARD_TYPE_FLAG_TITLE
|
Inherited constants |
---|
From
class
android.support.v17.leanback.widget.BaseCardView
|
From
class
android.view.ViewGroup
|
From
class
android.view.View
|
Inherited fields |
---|
From
class
android.view.View
|
Public constructors | |
---|---|
ImageCardView(Context context, int themeResId)
This constructor was deprecated in API level 24.1.0. Calling this constructor inefficiently creates one ContextThemeWrapper per card, you should share it in card Presenter: wrapper = new ContextThemeWrapper(context, themResId); return new ImageCardView(wrapper); |
|
ImageCardView(Context context, AttributeSet attrs, int defStyleAttr)
|
|
ImageCardView(Context context)
|
|
ImageCardView(Context context, AttributeSet attrs)
|
Public methods | |
---|---|
Drawable
|
getBadgeImage()
Returns the badge image drawable. |
CharSequence
|
getContentText()
Returns the content text. |
Drawable
|
getInfoAreaBackground()
Returns the info area background drawable. |
Drawable
|
getMainImage()
Returns the ImageView drawable. |
final
ImageView
|
getMainImageView()
Returns the main image view. |
CharSequence
|
getTitleText()
Returns the title text. |
boolean
|
hasOverlappingRendering()
|
void
|
setBadgeImage(Drawable drawable)
Sets the badge image drawable. |
void
|
setContentText(CharSequence text)
Sets the content text. |
void
|
setInfoAreaBackground(Drawable drawable)
Sets the info area background drawable. |
void
|
setInfoAreaBackgroundColor(int color)
Sets the info area background color. |
void
|
setMainImage(Drawable drawable, boolean fade)
Sets the image drawable with optional fade-in animation. |
void
|
setMainImage(Drawable drawable)
Sets the image drawable with fade-in animation. |
void
|
setMainImageAdjustViewBounds(boolean adjustViewBounds)
Enables or disables adjustment of view bounds on the main image. |
void
|
setMainImageDimensions(int width, int height)
Sets the layout dimensions of the ImageView. |
void
|
setMainImageScaleType(ImageView.ScaleType scaleType)
Sets the ScaleType of the main image. |
void
|
setTitleText(CharSequence text)
Sets the title text. |
Protected methods | |
---|---|
void
|
onAttachedToWindow()
|
void
|
onDetachedFromWindow()
|
Inherited methods | |
---|---|
From
class
android.support.v17.leanback.widget.BaseCardView
| |
From
class
android.widget.FrameLayout
| |
From
class
android.view.ViewGroup
| |
From
class
android.view.View
| |
From
class
java.lang.Object
| |
From
interface
android.view.ViewParent
| |
From
interface
android.view.ViewManager
| |
From
interface
android.graphics.drawable.Drawable.Callback
| |
From
interface
android.view.KeyEvent.Callback
| |
From
interface
android.view.accessibility.AccessibilityEventSource
|
XML attributes
LeanbackTheme_imageCardViewBadgeStyle
LeanbackTheme_imageCardViewContentStyle
LeanbackTheme_imageCardViewImageStyle
LeanbackTheme_imageCardViewInfoAreaStyle
LeanbackTheme_imageCardViewStyle
LeanbackTheme_imageCardViewTitleStyle
lbImageCardView_lbImageCardViewType
Constants
CARD_TYPE_FLAG_CONTENT
int CARD_TYPE_FLAG_CONTENT
Constant Value: 2 (0x00000002)
CARD_TYPE_FLAG_ICON_LEFT
int CARD_TYPE_FLAG_ICON_LEFT
Constant Value: 8 (0x00000008)
CARD_TYPE_FLAG_ICON_RIGHT
int CARD_TYPE_FLAG_ICON_RIGHT
Constant Value: 4 (0x00000004)
CARD_TYPE_FLAG_IMAGE_ONLY
int CARD_TYPE_FLAG_IMAGE_ONLY
Constant Value: 0 (0x00000000)
CARD_TYPE_FLAG_TITLE
int CARD_TYPE_FLAG_TITLE
Constant Value: 1 (0x00000001)
Public constructors
ImageCardView
ImageCardView (Context context, int themeResId)
This constructor was deprecated
in API level 24.1.0.
Calling this constructor inefficiently creates one ContextThemeWrapper per card,
you should share it in card Presenter: wrapper = new ContextThemeWrapper(context, themResId);
return new ImageCardView(wrapper);
Create an ImageCardView using a given theme for customization.
Parameters | |
---|---|
context |
Context : The Context the view is running in, through which it can
access the current theme, resources, etc. |
themeResId |
int : The resourceId of the theme you want to apply to the ImageCardView. The theme
includes attributes "imageCardViewStyle", "imageCardViewTitleStyle",
"imageCardViewContentStyle" etc. to customize individual part of ImageCardView. |
ImageCardView
ImageCardView (Context context, AttributeSet attrs, int defStyleAttr)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
defStyleAttr |
int |
ImageCardView
ImageCardView (Context context)
Parameters | |
---|---|
context |
Context |
See also:
ImageCardView
ImageCardView (Context context, AttributeSet attrs)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
See also:
Public methods
getBadgeImage
Drawable getBadgeImage ()
Returns the badge image drawable.
Returns | |
---|---|
Drawable |
getContentText
CharSequence getContentText ()
Returns the content text.
Returns | |
---|---|
CharSequence |
getInfoAreaBackground
Drawable getInfoAreaBackground ()
Returns the info area background drawable.
Returns | |
---|---|
Drawable |
getMainImage
Drawable getMainImage ()
Returns the ImageView drawable.
Returns | |
---|---|
Drawable |
getMainImageView
ImageView getMainImageView ()
Returns the main image view.
Returns | |
---|---|
ImageView |
getTitleText
CharSequence getTitleText ()
Returns the title text.
Returns | |
---|---|
CharSequence |
hasOverlappingRendering
boolean hasOverlappingRendering ()
Returns | |
---|---|
boolean |
setBadgeImage
void setBadgeImage (Drawable drawable)
Sets the badge image drawable.
Parameters | |
---|---|
drawable |
Drawable |
setContentText
void setContentText (CharSequence text)
Sets the content text.
Parameters | |
---|---|
text |
CharSequence |
setInfoAreaBackground
void setInfoAreaBackground (Drawable drawable)
Sets the info area background drawable.
Parameters | |
---|---|
drawable |
Drawable |
setInfoAreaBackgroundColor
void setInfoAreaBackgroundColor (int color)
Sets the info area background color.
Parameters | |
---|---|
color |
int |
setMainImage
void setMainImage (Drawable drawable, boolean fade)
Sets the image drawable with optional fade-in animation.
Parameters | |
---|---|
drawable |
Drawable |
fade |
boolean |
setMainImage
void setMainImage (Drawable drawable)
Sets the image drawable with fade-in animation.
Parameters | |
---|---|
drawable |
Drawable |
setMainImageAdjustViewBounds
void setMainImageAdjustViewBounds (boolean adjustViewBounds)
Enables or disables adjustment of view bounds on the main image.
Parameters | |
---|---|
adjustViewBounds |
boolean |
setMainImageDimensions
void setMainImageDimensions (int width, int height)
Sets the layout dimensions of the ImageView.
Parameters | |
---|---|
width |
int |
height |
int |
setMainImageScaleType
void setMainImageScaleType (ImageView.ScaleType scaleType)
Sets the ScaleType of the main image.
Parameters | |
---|---|
scaleType |
ImageView.ScaleType |
setTitleText
void setTitleText (CharSequence text)
Sets the title text.
Parameters | |
---|---|
text |
CharSequence |
Protected methods
onAttachedToWindow
void onAttachedToWindow ()
onDetachedFromWindow
void onDetachedFromWindow ()
Interfaces
- BaseGridView.OnKeyInterceptListener
- BaseGridView.OnMotionInterceptListener
- BaseGridView.OnTouchInterceptListener
- BaseGridView.OnUnhandledKeyListener
- BaseOnItemViewClickedListener
- BaseOnItemViewSelectedListener
- BrowseFrameLayout.OnChildFocusListener
- BrowseFrameLayout.OnFocusSearchListener
- FacetProvider
- FacetProviderAdapter
- FocusHighlight
- FragmentAnimationProvider
- ImeKeyMonitor
- ImeKeyMonitor.ImeKeyListener
- MultiActionsProvider
- OnActionClickedListener
- OnChildLaidOutListener
- OnChildSelectedListener
- OnItemViewClickedListener
- OnItemViewSelectedListener
- PlaybackSeekUi
- SearchBar.SearchBarListener
- SearchBar.SearchBarPermissionListener
- SearchEditText.OnKeyboardDismissListener
- SpeechRecognitionCallback
- TitleViewAdapter.Provider
- ViewHolderTask
Classes
- AbstractDetailsDescriptionPresenter
- AbstractDetailsDescriptionPresenter.ViewHolder
- AbstractMediaItemPresenter
- AbstractMediaItemPresenter.ViewHolder
- AbstractMediaListHeaderPresenter
- AbstractMediaListHeaderPresenter.ViewHolder
- Action
- ArrayObjectAdapter
- BaseCardView
- BaseCardView.LayoutParams
- BaseGridView
- BrowseFrameLayout
- ClassPresenterSelector
- ControlButtonPresenterSelector
- CursorObjectAdapter
- DetailsOverviewLogoPresenter
- DetailsOverviewLogoPresenter.ViewHolder
- DetailsOverviewRow
- DetailsOverviewRow.Listener
- DetailsOverviewRowPresenter
- DetailsOverviewRowPresenter.ViewHolder
- DetailsParallax
- DiffCallback
- DividerPresenter
- DividerRow
- FocusHighlightHelper
- FullWidthDetailsOverviewRowPresenter
- FullWidthDetailsOverviewRowPresenter.Listener
- FullWidthDetailsOverviewRowPresenter.ViewHolder
- FullWidthDetailsOverviewRowPresenter.ViewHolder.DetailsOverviewRowListener
- FullWidthDetailsOverviewSharedElementHelper
- GuidanceStylist
- GuidanceStylist.Guidance
- GuidedAction
- GuidedAction.Builder
- GuidedAction.BuilderBase
- GuidedActionDiffCallback
- GuidedActionEditText
- GuidedActionsStylist
- GuidedActionsStylist.ViewHolder
- GuidedDatePickerAction
- GuidedDatePickerAction.Builder
- GuidedDatePickerAction.BuilderBase
- HeaderItem
- HorizontalGridView
- HorizontalHoverCardSwitcher
- ImageCardView
- ItemAlignmentFacet
- ItemAlignmentFacet.ItemAlignmentDef
- ItemBridgeAdapter
- ItemBridgeAdapter.AdapterListener
- ItemBridgeAdapter.ViewHolder
- ItemBridgeAdapter.Wrapper
- ItemBridgeAdapterShadowOverlayWrapper
- ListRow
- ListRowHoverCardView
- ListRowPresenter
- ListRowPresenter.SelectItemViewHolderTask
- ListRowPresenter.ViewHolder
- ListRowView
- MultiActionsProvider.MultiAction
- ObjectAdapter
- ObjectAdapter.DataObserver
- OnChildViewHolderSelectedListener
- PageRow
- Parallax
- Parallax.FloatProperty
- Parallax.IntProperty
- Parallax.PropertyMarkerValue
- ParallaxEffect
- ParallaxTarget
- ParallaxTarget.DirectPropertyTarget
- ParallaxTarget.PropertyValuesHolderTarget
- PlaybackControlsRow
- PlaybackControlsRow.ClosedCaptioningAction
- PlaybackControlsRow.FastForwardAction
- PlaybackControlsRow.HighQualityAction
- PlaybackControlsRow.MoreActions
- PlaybackControlsRow.MultiAction
- PlaybackControlsRow.OnPlaybackProgressCallback
- PlaybackControlsRow.PictureInPictureAction
- PlaybackControlsRow.PlayPauseAction
- PlaybackControlsRow.RepeatAction
- PlaybackControlsRow.RewindAction
- PlaybackControlsRow.ShuffleAction
- PlaybackControlsRow.SkipNextAction
- PlaybackControlsRow.SkipPreviousAction
- PlaybackControlsRow.ThumbsAction
- PlaybackControlsRow.ThumbsDownAction
- PlaybackControlsRow.ThumbsUpAction
- PlaybackControlsRowPresenter
- PlaybackControlsRowPresenter.ViewHolder
- PlaybackRowPresenter
- PlaybackRowPresenter.ViewHolder
- PlaybackSeekDataProvider
- PlaybackSeekDataProvider.ResultCallback
- PlaybackSeekUi.Client
- PlaybackTransportRowPresenter
- PlaybackTransportRowPresenter.ViewHolder
- Presenter
- Presenter.ViewHolder
- Presenter.ViewHolderTask
- PresenterSelector
- PresenterSwitcher
- RecyclerViewParallax
- RecyclerViewParallax.ChildPositionProperty
- Row
- RowHeaderPresenter
- RowHeaderPresenter.ViewHolder
- RowHeaderView
- RowPresenter
- RowPresenter.ViewHolder
- SearchBar
- SearchEditText
- SearchOrbView
- SearchOrbView.Colors
- SectionRow
- ShadowOverlayContainer
- ShadowOverlayHelper
- ShadowOverlayHelper.Builder
- ShadowOverlayHelper.Options
- SinglePresenterSelector
- SparseArrayObjectAdapter
- SpeechOrbView
- TitleHelper
- TitleView
- TitleViewAdapter
- VerticalGridPresenter
- VerticalGridPresenter.ViewHolder
- VerticalGridView
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-11 UTC.