CardFrame

public class CardFrame
extends ViewGroup

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.support.wearable.view.CardFrame


Wraps a view in a card-styled frame with a white background, rounded corners and a light drop-shadow. This layout is designed to be given a height of WRAP_CONTENT within a container with a fixed height.

To function properly, this view should be contained within a CardScrollView. A CardFragment provides this automatically.

Summary

Constants

int EXPAND_DOWN

int EXPAND_UP

float NO_EXPANSION

Inherited constants

From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.ViewGroup
From class android.view.View

Public constructors

CardFrame(Context context)
CardFrame(Context context, AttributeSet attrs)
CardFrame(Context context, AttributeSet attrs, int defStyle)

Public methods

void addView(View child, int index)
void addView(View child, ViewGroup.LayoutParams params)
void addView(View child)
void addView(View child, int index, ViewGroup.LayoutParams params)
int getContentPaddingBottom()

Returns the inner padding before the Card's bottom edge

int getContentPaddingLeft()

Returns the inner padding after the Card's left edge

int getContentPaddingRight()

Returns the inner padding before the Card's right edge

int getContentPaddingTop()

Returns the inner padding after the Card's top edge

static int getDefaultSize(int size, int measureSpec, boolean greedy)

Get a default size, will be as small as possible unless forced by the parent, or greedy is specified.

int getExpansionDirection()

Returns the current expansion direction, either EXPAND_UP or EXPAND_DOWN.

float getExpansionFactor()

Returns the current expansionFactor which is the maximum height of this view as a multiple of the parent view's height.

boolean isExpansionEnabled()

Indicates whether expansion is on.

WindowInsets onApplyWindowInsets(WindowInsets insets)
void onInitializeAccessibilityEvent(AccessibilityEvent event)
void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
void setExpansionDirection(int direction)

Sets the direction in which content expands.

void setExpansionEnabled(boolean enabled)

Enables support contents which maybe be larger than the card's container.

void setExpansionFactor(float expansionFactor)

Sets the allowed expansion amount as a multiple of the parent height.

boolean shouldDelayChildPressedState()

Protected methods

boolean drawChild(Canvas canvas, View child, long drawingTime)
void onAttachedToWindow()
void onLayout(boolean changed, int left, int top, int right, int bottom)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Inherited methods

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

Constants

EXPAND_DOWN

int EXPAND_DOWN

Constant Value: 1 (0x00000001)

EXPAND_UP

int EXPAND_UP

Constant Value: -1 (0xffffffff)

NO_EXPANSION

float NO_EXPANSION

Constant Value: 1.0

Public constructors

CardFrame

CardFrame (Context context)

Parameters
context Context

CardFrame

CardFrame (Context context,
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

CardFrame

CardFrame (Context context,
                AttributeSet attrs,
                int defStyle)

Parameters
context Context
attrs AttributeSet
defStyle int

Public methods

addView

void addView (View child,
                int index)

Parameters
child View
index int

addView

void addView (View child,
                ViewGroup.LayoutParams params)

Parameters
child View
params ViewGroup.LayoutParams

addView

void addView (View child)

Parameters
child View

addView

void addView (View child,
                int index,
                ViewGroup.LayoutParams params)

Parameters
child View
index int
params ViewGroup.LayoutParams

getContentPaddingBottom

int getContentPaddingBottom ()

Returns the inner padding before the Card's bottom edge

Returns
int

getContentPaddingLeft

int getContentPaddingLeft ()

Returns the inner padding after the Card's left edge

Returns
int

getContentPaddingRight

int getContentPaddingRight ()

Returns the inner padding before the Card's right edge

Returns
int

getContentPaddingTop

int getContentPaddingTop ()

Returns the inner padding after the Card's top edge

Returns
int

getDefaultSize

int getDefaultSize (int size,
                int measureSpec,
                boolean greedy)

Get a default size, will be as small as possible unless forced by the parent, or greedy is specified.

Parameters
size int
measureSpec int
greedy boolean
Returns
int

getExpansionDirection

int getExpansionDirection ()

Returns the current expansion direction, either EXPAND_UP or EXPAND_DOWN.

Returns
int

getExpansionFactor

float getExpansionFactor ()

Returns the current expansionFactor which is the maximum height of this view as a multiple of the parent view's height.

Returns
float

isExpansionEnabled

boolean isExpansionEnabled ()

Indicates whether expansion is on. A CardFrame will increase in height up to expansionFactor times the parent view's height. When expansion is enabled, content which is taller than this will have a fading effect applied to the expanding edge, otherwise content is simply clipped.

Returns
boolean

onApplyWindowInsets

WindowInsets onApplyWindowInsets (WindowInsets insets)

Parameters
insets WindowInsets
Returns
WindowInsets

onInitializeAccessibilityEvent

void onInitializeAccessibilityEvent (AccessibilityEvent event)

Parameters
event AccessibilityEvent

onInitializeAccessibilityNodeInfo

void onInitializeAccessibilityNodeInfo (AccessibilityNodeInfo info)

Parameters
info AccessibilityNodeInfo

setExpansionDirection

void setExpansionDirection (int direction)

Sets the direction in which content expands. Determines whether the top or bottom edge receives the fading edge appearance and whether more content is viewed by scrolling up or down, after increasing the expansion factor.

Parameters
direction int

setExpansionEnabled

void setExpansionEnabled (boolean enabled)

Enables support contents which maybe be larger than the card's container. When expansion is enabled, and the contents are larger than the card, the top or bottom edge will fade to indicate this. The expansion factor must also be increased to allow the card to increase in height.

Parameters
enabled boolean

setExpansionFactor

void setExpansionFactor (float expansionFactor)

Sets the allowed expansion amount as a multiple of the parent height. If expansion is enabled, the card will grow up to this height as needed to accommodate content.

Parameters
expansionFactor float

shouldDelayChildPressedState

boolean shouldDelayChildPressedState ()

Returns
boolean

Protected methods

drawChild

boolean drawChild (Canvas canvas,
                View child,
                long drawingTime)

Parameters
canvas Canvas
child View
drawingTime long
Returns
boolean

onAttachedToWindow

void onAttachedToWindow ()

onLayout

void onLayout (boolean changed,
                int left,
                int top,
                int right,
                int bottom)

Parameters
changed boolean
left int
top int
right int
bottom int

onMeasure

void onMeasure (int widthMeasureSpec,
                int heightMeasureSpec)

Parameters
widthMeasureSpec int
heightMeasureSpec int