CardFrame

public class CardFrame
extends ViewGroup

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


This class is deprecated.
starting with Android Wear 2.0 it is no longer encouraged to use cards for apps' UI. If you are looking to implement vertical paging pattern, consider using the SnapHelper and a RecyclerView instead.

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

Inherited fields

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

Constants

EXPAND_DOWN

public static final int EXPAND_DOWN

Constant Value: 1 (0x00000001)

EXPAND_UP

public static final int EXPAND_UP

Constant Value: -1 (0xffffffff)

NO_EXPANSION

public static final float NO_EXPANSION

Constant Value: 1.0

Public constructors

CardFrame

public CardFrame (Context context)

Parameters
context Context

CardFrame

public CardFrame (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

CardFrame

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

Parameters
context Context

attrs AttributeSet

defStyle int

Public methods

addView

public void addView (View child, 
                int index)

Parameters
child View

index int

addView

public void addView (View child, 
                ViewGroup.LayoutParams params)

Parameters
child View

params ViewGroup.LayoutParams

addView

public void addView (View child)

Parameters
child View

addView

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

Parameters
child View

index int

params ViewGroup.LayoutParams

getContentPaddingBottom

public int getContentPaddingBottom ()

Returns the inner padding before the Card's bottom edge

Returns
int

getContentPaddingLeft

public int getContentPaddingLeft ()

Returns the inner padding after the Card's left edge

Returns
int

getContentPaddingRight

public int getContentPaddingRight ()

Returns the inner padding before the Card's right edge

Returns
int

getContentPaddingTop

public int getContentPaddingTop ()

Returns the inner padding after the Card's top edge

Returns
int

getDefaultSize

public 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.

Parameters
size int

measureSpec int

greedy boolean

Returns
int

getExpansionDirection

public int getExpansionDirection ()

Returns the current expansion direction, either EXPAND_UP or EXPAND_DOWN.

Returns
int

getExpansionFactor

public 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

public 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

public WindowInsets onApplyWindowInsets (WindowInsets insets)

Parameters
insets WindowInsets

Returns
WindowInsets

onInitializeAccessibilityEvent

public void onInitializeAccessibilityEvent (AccessibilityEvent event)

Parameters
event AccessibilityEvent

onInitializeAccessibilityNodeInfo

public void onInitializeAccessibilityNodeInfo (AccessibilityNodeInfo info)

Parameters
info AccessibilityNodeInfo

setExpansionDirection

public 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

public 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

public 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

public boolean shouldDelayChildPressedState ()

Returns
boolean

Protected methods

drawChild

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

Parameters
canvas Canvas

child View

drawingTime long

Returns
boolean

onAttachedToWindow

protected void onAttachedToWindow ()

onLayout

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

Parameters
changed boolean

left int

top int

right int

bottom int

onMeasure

protected void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Parameters
widthMeasureSpec int

heightMeasureSpec int