# CardFragment

Summary:[Constants](https://developer.android.com/reference/android/support/wearable/view/CardFragment#constants)\|[Inherited Constants](https://developer.android.com/reference/android/support/wearable/view/CardFragment#inhconstants)\|[Ctors](https://developer.android.com/reference/android/support/wearable/view/CardFragment#pubctors)\|[Methods](https://developer.android.com/reference/android/support/wearable/view/CardFragment#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/wearable/view/CardFragment#inhmethods)  

# CardFragment

`
public


class
CardFragment
`  
`


``

extends `[Fragment](http://developer.android.com/reference/android/app/Fragment.html)`


``


`

|---|---|--------------------------------------------|
| [java.lang.Object](http://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [android.app.Fragment](http://developer.android.com/reference/android/app/Fragment.html) ||
|   | ↳ | android.support.wearable.view.CardFragment |

<br />

*** ** * ** ***

<br />

**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](https://developer.android.com/reference/android/support/v7/widget/SnapHelper.html)and a[RecyclerView](https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html)instead.

Presents content within an expandable, vertically scrollable card. The default layout contains a title, icon and text, but may be replaced by overriding[onCreateContentView(LayoutInflater, ViewGroup, Bundle)](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#onCreateContentView(android.view.LayoutInflater,%20android.view.ViewGroup,%20android.os.Bundle)).

Additional methods are supplied for adjusting the appearance of the card, including whether content should clip or appear as expandable, and the maximum height of the card.  
**See also:**

- [setCardGravity(int)](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setCardGravity(int))
- [setExpansionEnabled(boolean)](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setExpansionEnabled(boolean))
- [setExpansionDirection(int)](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setExpansionDirection(int))
- [setExpansionFactor(float)](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setExpansionFactor(float))

## Summary

|                                                                                                 ### Constants                                                                                                 ||
|------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| `int`                                                                  | [EXPAND_DOWN](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#EXPAND_DOWN) <br />             |
| `int`                                                                  | [EXPAND_UP](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#EXPAND_UP) <br />                 |
| [String](http://developer.android.com/reference/java/lang/String.html) | [KEY_ICON_RESOURCE](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#KEY_ICON_RESOURCE) <br /> |
| [String](http://developer.android.com/reference/java/lang/String.html) | [KEY_TEXT](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#KEY_TEXT) <br />                   |
| [String](http://developer.android.com/reference/java/lang/String.html) | [KEY_TITLE](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#KEY_TITLE) <br />                 |

|                                                                                                                                                                                                                       ### Inherited constants                                                                                                                                                                                                                       |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From interface`android.content.ComponentCallbacks2` |-------|---------------------------------------| | `int` | `TRIM_MEMORY_BACKGROUND` <br />       | | `int` | `TRIM_MEMORY_COMPLETE` <br />         | | `int` | `TRIM_MEMORY_MODERATE` <br />         | | `int` | `TRIM_MEMORY_RUNNING_CRITICAL` <br /> | | `int` | `TRIM_MEMORY_RUNNING_LOW` <br />      | | `int` | `TRIM_MEMORY_RUNNING_MODERATE` <br /> | | `int` | `TRIM_MEMORY_UI_HIDDEN` <br />        | |

|                                                      ### Public constructors                                                      ||
|--------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[CardFragment](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#CardFragment())`() ` |

|                                                                                                                                                                                                                                                                                                                                                       ### Public methods                                                                                                                                                                                                                                                                                                                                                       ||
|-------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static `[CardFragment](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html) | ` `[create](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#create(java.lang.CharSequence,%20java.lang.CharSequence,%20int))`(`[CharSequence](http://developer.android.com/reference/java/lang/CharSequence.html)` title, `[CharSequence](http://developer.android.com/reference/java/lang/CharSequence.html)` text, int iconRes) ` Construct a new CardFragment using the default content layout, including and icon.                                                                                                                                              |
| ` static `[CardFragment](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html) | ` `[create](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#create(java.lang.CharSequence,%20java.lang.CharSequence))`(`[CharSequence](http://developer.android.com/reference/java/lang/CharSequence.html)` title, `[CharSequence](http://developer.android.com/reference/java/lang/CharSequence.html)` description) ` Construct a new CardFragment using the default content layout.                                                                                                                                                                               |
| ` `[Rect](http://developer.android.com/reference/android/graphics/Rect.html)                                      | ` `[getContentPadding](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#getContentPadding())`() ` Gets the padding between the inside card edge and the card content.                                                                                                                                                                                                                                                                                                                                                                                                |
| ` int`                                                                                                            | ` `[getContentPaddingBottom](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#getContentPaddingBottom())`() ` Gets the padding between the inside card's bottom edge and the card content.                                                                                                                                                                                                                                                                                                                                                                           |
| ` int`                                                                                                            | ` `[getContentPaddingLeft](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#getContentPaddingLeft())`() ` Gets the padding between the inside card's left edge and the card content.                                                                                                                                                                                                                                                                                                                                                                                 |
| ` int`                                                                                                            | ` `[getContentPaddingRight](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#getContentPaddingRight())`() ` Gets the padding between the inside card's right edge and the card content.                                                                                                                                                                                                                                                                                                                                                                              |
| ` int`                                                                                                            | ` `[getContentPaddingTop](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#getContentPaddingTop())`() ` Gets the padding between the inside card's top edge and the card content.                                                                                                                                                                                                                                                                                                                                                                                    |
| ` void`                                                                                                           | ` `[onActivityCreated](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#onActivityCreated(android.os.Bundle))`(`[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` savedInstanceState) `                                                                                                                                                                                                                                                                                                                                                       |
| ` `[View](http://developer.android.com/reference/android/view/View.html)                                          | ` `[onCreateContentView](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#onCreateContentView(android.view.LayoutInflater,%20android.view.ViewGroup,%20android.os.Bundle))`(`[LayoutInflater](http://developer.android.com/reference/android/view/LayoutInflater.html)` inflater, `[ViewGroup](http://developer.android.com/reference/android/view/ViewGroup.html)` container, `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` savedInstanceState) ` Called to have subclasses instantiate their layout which is inserted within the card. |
| ` final `[View](http://developer.android.com/reference/android/view/View.html)                                    | ` `[onCreateView](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#onCreateView(android.view.LayoutInflater,%20android.view.ViewGroup,%20android.os.Bundle))`(`[LayoutInflater](http://developer.android.com/reference/android/view/LayoutInflater.html)` inflater, `[ViewGroup](http://developer.android.com/reference/android/view/ViewGroup.html)` container, `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` savedInstanceState) `                                                                                                     |
| ` void`                                                                                                           | ` `[onDestroy](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#onDestroy())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` void`                                                                                                           | ` `[scrollToBottom](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#scrollToBottom())`() ` Sets the card scroll position as far down as possible so the bottom edge is visible.                                                                                                                                                                                                                                                                                                                                                                                     |
| ` void`                                                                                                           | ` `[scrollToTop](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#scrollToTop())`() ` Sets the card scroll position as far up as possible so the top edge is visible.                                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                                                           | ` `[setCardGravity](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setCardGravity(int))`(int gravity) ` Assigns vertical gravity to the card, which determines where it should float when the card and it's content are shorter than the page.                                                                                                                                                                                                                                                                                                                     |
| ` void`                                                                                                           | ` `[setCardMarginBottom](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setCardMarginBottom(int))`(int bottom) ` Sets the additional margin between the bottom edge of the card shadow, and the parent view.                                                                                                                                                                                                                                                                                                                                                       |
| ` void`                                                                                                           | ` `[setCardMarginLeft](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setCardMarginLeft(int))`(int left) ` Sets the additional margin between the left edge of the card shadow, and the parent view.                                                                                                                                                                                                                                                                                                                                                               |
| ` void`                                                                                                           | ` `[setCardMarginRight](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setCardMarginRight(int))`(int right) ` Sets the additional margin between the right edge of the card shadow, and the parent view.                                                                                                                                                                                                                                                                                                                                                           |
| ` void`                                                                                                           | ` `[setCardMarginTop](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setCardMarginTop(int))`(int top) ` Sets the additional margin between the top edge of the card shadow, and the parent view.                                                                                                                                                                                                                                                                                                                                                                   |
| ` void`                                                                                                           | ` `[setCardMargins](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setCardMargins(int,%20int,%20int,%20int))`(int left, int top, int right, int bottom) ` Sets the additional margin between the card shadow edge and the parent view.                                                                                                                                                                                                                                                                                                                             |
| ` void`                                                                                                           | ` `[setContentPadding](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setContentPadding(int,%20int,%20int,%20int))`(int left, int top, int right, int bottom) ` Sets padding between the inside card edge and the card content.                                                                                                                                                                                                                                                                                                                                    |
| ` void`                                                                                                           | ` `[setContentPaddingBottom](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setContentPaddingBottom(int))`(int bottomPadding) ` Sets the padding between the inside card's bottom edge and the card content.                                                                                                                                                                                                                                                                                                                                                       |
| ` void`                                                                                                           | ` `[setContentPaddingLeft](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setContentPaddingLeft(int))`(int leftPadding) ` Sets the padding between the inside card's left edge and the card content.                                                                                                                                                                                                                                                                                                                                                               |
| ` void`                                                                                                           | ` `[setContentPaddingRight](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setContentPaddingRight(int))`(int rightPadding) ` Sets the padding between the inside card's right edge and the card content.                                                                                                                                                                                                                                                                                                                                                           |
| ` void`                                                                                                           | ` `[setContentPaddingTop](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setContentPaddingTop(int))`(int topPadding) ` Sets the padding between the inside card's top edge and the card content.                                                                                                                                                                                                                                                                                                                                                                   |
| ` void`                                                                                                           | ` `[setExpansionDirection](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setExpansionDirection(int))`(int direction) ` Adjusts which direction the card height will expand.                                                                                                                                                                                                                                                                                                                                                                                       |
| ` void`                                                                                                           | ` `[setExpansionEnabled](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setExpansionEnabled(boolean))`(boolean enabled) ` Enables support contents which maybe be larger than the card's container.                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                                                           | ` `[setExpansionFactor](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#setExpansionFactor(float))`(float factor) ` Sets the allowed maximum height of the card as a multiple of the parent height.                                                                                                                                                                                                                                                                                                                                                                 |

| ### Inherited methods |
|-----------------------|---|
| From class` `[android.app.Fragment](http://developer.android.com/reference/android/app/Fragment.html)` ` |-----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                                                             | ` dump(`[String](http://developer.android.com/reference/java/lang/String.html)` arg0, `[FileDescriptor](http://developer.android.com/reference/java/io/FileDescriptor.html)` arg1, `[PrintWriter](http://developer.android.com/reference/java/io/PrintWriter.html)` arg2, `[String[]](http://developer.android.com/reference/java/lang/String.html)` arg3) ` | | ` final boolean`                                                                                    | ` equals(`[Object](http://developer.android.com/reference/java/lang/Object.html)` arg0) `                                                                                                                                                                                                                                                                    | | ` final `[Activity](http://developer.android.com/reference/android/app/Activity.html)               | ` getActivity() `                                                                                                                                                                                                                                                                                                                                            | | ` boolean`                                                                                          | ` getAllowEnterTransitionOverlap() `                                                                                                                                                                                                                                                                                                                         | | ` boolean`                                                                                          | ` getAllowReturnTransitionOverlap() `                                                                                                                                                                                                                                                                                                                        | | ` final `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)                    | ` getArguments() `                                                                                                                                                                                                                                                                                                                                           | | ` final `[FragmentManager](http://developer.android.com/reference/android/app/FragmentManager.html) | ` getChildFragmentManager() `                                                                                                                                                                                                                                                                                                                                | | ` `[Context](http://developer.android.com/reference/android/content/Context.html)                   | ` getContext() `                                                                                                                                                                                                                                                                                                                                             | | ` `[Transition](http://developer.android.com/reference/android/transition/Transition.html)          | ` getEnterTransition() `                                                                                                                                                                                                                                                                                                                                     | | ` `[Transition](http://developer.android.com/reference/android/transition/Transition.html)          | ` getExitTransition() `                                                                                                                                                                                                                                                                                                                                      | | ` final `[FragmentManager](http://developer.android.com/reference/android/app/FragmentManager.html) | ` getFragmentManager() `                                                                                                                                                                                                                                                                                                                                     | | ` final `[Object](http://developer.android.com/reference/java/lang/Object.html)                     | ` getHost() `                                                                                                                                                                                                                                                                                                                                                | | ` final int`                                                                                        | ` getId() `                                                                                                                                                                                                                                                                                                                                                  | | ` final `[LayoutInflater](http://developer.android.com/reference/android/view/LayoutInflater.html)  | ` getLayoutInflater() `                                                                                                                                                                                                                                                                                                                                      | | ` `[LoaderManager](http://developer.android.com/reference/android/app/LoaderManager.html)           | ` getLoaderManager() `                                                                                                                                                                                                                                                                                                                                       | | ` final `[Fragment](http://developer.android.com/reference/android/app/Fragment.html)               | ` getParentFragment() `                                                                                                                                                                                                                                                                                                                                      | | ` `[Transition](http://developer.android.com/reference/android/transition/Transition.html)          | ` getReenterTransition() `                                                                                                                                                                                                                                                                                                                                   | | ` final `[Resources](http://developer.android.com/reference/android/content/res/Resources.html)     | ` getResources() `                                                                                                                                                                                                                                                                                                                                           | | ` final boolean`                                                                                    | ` getRetainInstance() `                                                                                                                                                                                                                                                                                                                                      | | ` `[Transition](http://developer.android.com/reference/android/transition/Transition.html)          | ` getReturnTransition() `                                                                                                                                                                                                                                                                                                                                    | | ` `[Transition](http://developer.android.com/reference/android/transition/Transition.html)          | ` getSharedElementEnterTransition() `                                                                                                                                                                                                                                                                                                                        | | ` `[Transition](http://developer.android.com/reference/android/transition/Transition.html)          | ` getSharedElementReturnTransition() `                                                                                                                                                                                                                                                                                                                       | | ` final `[String](http://developer.android.com/reference/java/lang/String.html)                     | ` getString(int arg0, `[Object...](http://developer.android.com/reference/java/lang/Object.html)` arg1) `                                                                                                                                                                                                                                                    | | ` final `[String](http://developer.android.com/reference/java/lang/String.html)                     | ` getString(int arg0) `                                                                                                                                                                                                                                                                                                                                      | | ` final `[String](http://developer.android.com/reference/java/lang/String.html)                     | ` getTag() `                                                                                                                                                                                                                                                                                                                                                 | | ` final `[Fragment](http://developer.android.com/reference/android/app/Fragment.html)               | ` getTargetFragment() `                                                                                                                                                                                                                                                                                                                                      | | ` final int`                                                                                        | ` getTargetRequestCode() `                                                                                                                                                                                                                                                                                                                                   | | ` final `[CharSequence](http://developer.android.com/reference/java/lang/CharSequence.html)         | ` getText(int arg0) `                                                                                                                                                                                                                                                                                                                                        | | ` boolean`                                                                                          | ` getUserVisibleHint() `                                                                                                                                                                                                                                                                                                                                     | | ` `[View](http://developer.android.com/reference/android/view/View.html)                            | ` getView() `                                                                                                                                                                                                                                                                                                                                                | | ` final int`                                                                                        | ` hashCode() `                                                                                                                                                                                                                                                                                                                                               | | ` static `[Fragment](http://developer.android.com/reference/android/app/Fragment.html)              | ` instantiate(`[Context](http://developer.android.com/reference/android/content/Context.html)` arg0, `[String](http://developer.android.com/reference/java/lang/String.html)` arg1) `                                                                                                                                                                        | | ` static `[Fragment](http://developer.android.com/reference/android/app/Fragment.html)              | ` instantiate(`[Context](http://developer.android.com/reference/android/content/Context.html)` arg0, `[String](http://developer.android.com/reference/java/lang/String.html)` arg1, `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg2) `                                                                                        | | ` final boolean`                                                                                    | ` isAdded() `                                                                                                                                                                                                                                                                                                                                                | | ` final boolean`                                                                                    | ` isDetached() `                                                                                                                                                                                                                                                                                                                                             | | ` final boolean`                                                                                    | ` isHidden() `                                                                                                                                                                                                                                                                                                                                               | | ` final boolean`                                                                                    | ` isInLayout() `                                                                                                                                                                                                                                                                                                                                             | | ` final boolean`                                                                                    | ` isRemoving() `                                                                                                                                                                                                                                                                                                                                             | | ` final boolean`                                                                                    | ` isResumed() `                                                                                                                                                                                                                                                                                                                                              | | ` final boolean`                                                                                    | ` isStateSaved() `                                                                                                                                                                                                                                                                                                                                           | | ` final boolean`                                                                                    | ` isVisible() `                                                                                                                                                                                                                                                                                                                                              | | ` void`                                                                                             | ` onActivityCreated(`[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg0) `                                                                                                                                                                                                                                                        | | ` void`                                                                                             | ` onActivityResult(int arg0, int arg1, `[Intent](http://developer.android.com/reference/android/content/Intent.html)` arg2) `                                                                                                                                                                                                                                | | ` void`                                                                                             | ` onAttach(`[Activity](http://developer.android.com/reference/android/app/Activity.html)` arg0) `                                                                                                                                                                                                                                                            | | ` void`                                                                                             | ` onAttach(`[Context](http://developer.android.com/reference/android/content/Context.html)` arg0) `                                                                                                                                                                                                                                                          | | ` void`                                                                                             | ` onAttachFragment(`[Fragment](http://developer.android.com/reference/android/app/Fragment.html)` arg0) `                                                                                                                                                                                                                                                    | | ` void`                                                                                             | ` onConfigurationChanged(`[Configuration](http://developer.android.com/reference/android/content/res/Configuration.html)` arg0) `                                                                                                                                                                                                                            | | ` boolean`                                                                                          | ` onContextItemSelected(`[MenuItem](http://developer.android.com/reference/android/view/MenuItem.html)` arg0) `                                                                                                                                                                                                                                              | | ` void`                                                                                             | ` onCreate(`[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg0) `                                                                                                                                                                                                                                                                 | | ` `[Animator](http://developer.android.com/reference/android/animation/Animator.html)               | ` onCreateAnimator(int arg0, boolean arg1, int arg2) `                                                                                                                                                                                                                                                                                                       | | ` void`                                                                                             | ` onCreateContextMenu(`[ContextMenu](http://developer.android.com/reference/android/view/ContextMenu.html)` arg0, `[View](http://developer.android.com/reference/android/view/View.html)` arg1, `[ContextMenu.ContextMenuInfo](http://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo.html)` arg2) `                                | | ` void`                                                                                             | ` onCreateOptionsMenu(`[Menu](http://developer.android.com/reference/android/view/Menu.html)` arg0, `[MenuInflater](http://developer.android.com/reference/android/view/MenuInflater.html)` arg1) `                                                                                                                                                          | | ` `[View](http://developer.android.com/reference/android/view/View.html)                            | ` onCreateView(`[LayoutInflater](http://developer.android.com/reference/android/view/LayoutInflater.html)` arg0, `[ViewGroup](http://developer.android.com/reference/android/view/ViewGroup.html)` arg1, `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg2) `                                                                   | | ` void`                                                                                             | ` onDestroy() `                                                                                                                                                                                                                                                                                                                                              | | ` void`                                                                                             | ` onDestroyOptionsMenu() `                                                                                                                                                                                                                                                                                                                                   | | ` void`                                                                                             | ` onDestroyView() `                                                                                                                                                                                                                                                                                                                                          | | ` void`                                                                                             | ` onDetach() `                                                                                                                                                                                                                                                                                                                                               | | ` `[LayoutInflater](http://developer.android.com/reference/android/view/LayoutInflater.html)        | ` onGetLayoutInflater(`[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg0) `                                                                                                                                                                                                                                                      | | ` void`                                                                                             | ` onHiddenChanged(boolean arg0) `                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                             | ` onInflate(`[AttributeSet](http://developer.android.com/reference/android/util/AttributeSet.html)` arg0, `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg1) `                                                                                                                                                                  | | ` void`                                                                                             | ` onInflate(`[Activity](http://developer.android.com/reference/android/app/Activity.html)` arg0, `[AttributeSet](http://developer.android.com/reference/android/util/AttributeSet.html)` arg1, `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg2) `                                                                             | | ` void`                                                                                             | ` onInflate(`[Context](http://developer.android.com/reference/android/content/Context.html)` arg0, `[AttributeSet](http://developer.android.com/reference/android/util/AttributeSet.html)` arg1, `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg2) `                                                                           | | ` void`                                                                                             | ` onLowMemory() `                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                             | ` onMultiWindowModeChanged(boolean arg0) `                                                                                                                                                                                                                                                                                                                   | | ` void`                                                                                             | ` onMultiWindowModeChanged(boolean arg0, `[Configuration](http://developer.android.com/reference/android/content/res/Configuration.html)` arg1) `                                                                                                                                                                                                            | | ` boolean`                                                                                          | ` onOptionsItemSelected(`[MenuItem](http://developer.android.com/reference/android/view/MenuItem.html)` arg0) `                                                                                                                                                                                                                                              | | ` void`                                                                                             | ` onOptionsMenuClosed(`[Menu](http://developer.android.com/reference/android/view/Menu.html)` arg0) `                                                                                                                                                                                                                                                        | | ` void`                                                                                             | ` onPause() `                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                             | ` onPictureInPictureModeChanged(boolean arg0, `[Configuration](http://developer.android.com/reference/android/content/res/Configuration.html)` arg1) `                                                                                                                                                                                                       | | ` void`                                                                                             | ` onPictureInPictureModeChanged(boolean arg0) `                                                                                                                                                                                                                                                                                                              | | ` void`                                                                                             | ` onPrepareOptionsMenu(`[Menu](http://developer.android.com/reference/android/view/Menu.html)` arg0) `                                                                                                                                                                                                                                                       | | ` void`                                                                                             | ` onRequestPermissionsResult(int arg0, `[String[]](http://developer.android.com/reference/java/lang/String.html)` arg1, int[] arg2) `                                                                                                                                                                                                                        | | ` void`                                                                                             | ` onResume() `                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                             | ` onSaveInstanceState(`[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg0) `                                                                                                                                                                                                                                                      | | ` void`                                                                                             | ` onStart() `                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                             | ` onStop() `                                                                                                                                                                                                                                                                                                                                                 | | ` void`                                                                                             | ` onTrimMemory(int arg0) `                                                                                                                                                                                                                                                                                                                                   | | ` void`                                                                                             | ` onViewCreated(`[View](http://developer.android.com/reference/android/view/View.html)` arg0, `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg1) `                                                                                                                                                                              | | ` void`                                                                                             | ` onViewStateRestored(`[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg0) `                                                                                                                                                                                                                                                      | | ` void`                                                                                             | ` postponeEnterTransition() `                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                             | ` registerForContextMenu(`[View](http://developer.android.com/reference/android/view/View.html)` arg0) `                                                                                                                                                                                                                                                     | | ` final void`                                                                                       | ` requestPermissions(`[String[]](http://developer.android.com/reference/java/lang/String.html)` arg0, int arg1) `                                                                                                                                                                                                                                            | | ` void`                                                                                             | ` setAllowEnterTransitionOverlap(boolean arg0) `                                                                                                                                                                                                                                                                                                             | | ` void`                                                                                             | ` setAllowReturnTransitionOverlap(boolean arg0) `                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                             | ` setArguments(`[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg0) `                                                                                                                                                                                                                                                             | | ` void`                                                                                             | ` setEnterSharedElementCallback(`[SharedElementCallback](http://developer.android.com/reference/android/app/SharedElementCallback.html)` arg0) `                                                                                                                                                                                                             | | ` void`                                                                                             | ` setEnterTransition(`[Transition](http://developer.android.com/reference/android/transition/Transition.html)` arg0) `                                                                                                                                                                                                                                       | | ` void`                                                                                             | ` setExitSharedElementCallback(`[SharedElementCallback](http://developer.android.com/reference/android/app/SharedElementCallback.html)` arg0) `                                                                                                                                                                                                              | | ` void`                                                                                             | ` setExitTransition(`[Transition](http://developer.android.com/reference/android/transition/Transition.html)` arg0) `                                                                                                                                                                                                                                        | | ` void`                                                                                             | ` setHasOptionsMenu(boolean arg0) `                                                                                                                                                                                                                                                                                                                          | | ` void`                                                                                             | ` setInitialSavedState(`[Fragment.SavedState](http://developer.android.com/reference/android/app/Fragment.SavedState.html)` arg0) `                                                                                                                                                                                                                          | | ` void`                                                                                             | ` setMenuVisibility(boolean arg0) `                                                                                                                                                                                                                                                                                                                          | | ` void`                                                                                             | ` setReenterTransition(`[Transition](http://developer.android.com/reference/android/transition/Transition.html)` arg0) `                                                                                                                                                                                                                                     | | ` void`                                                                                             | ` setRetainInstance(boolean arg0) `                                                                                                                                                                                                                                                                                                                          | | ` void`                                                                                             | ` setReturnTransition(`[Transition](http://developer.android.com/reference/android/transition/Transition.html)` arg0) `                                                                                                                                                                                                                                      | | ` void`                                                                                             | ` setSharedElementEnterTransition(`[Transition](http://developer.android.com/reference/android/transition/Transition.html)` arg0) `                                                                                                                                                                                                                          | | ` void`                                                                                             | ` setSharedElementReturnTransition(`[Transition](http://developer.android.com/reference/android/transition/Transition.html)` arg0) `                                                                                                                                                                                                                         | | ` void`                                                                                             | ` setTargetFragment(`[Fragment](http://developer.android.com/reference/android/app/Fragment.html)` arg0, int arg1) `                                                                                                                                                                                                                                         | | ` void`                                                                                             | ` setUserVisibleHint(boolean arg0) `                                                                                                                                                                                                                                                                                                                         | | ` boolean`                                                                                          | ` shouldShowRequestPermissionRationale(`[String](http://developer.android.com/reference/java/lang/String.html)` arg0) `                                                                                                                                                                                                                                      | | ` void`                                                                                             | ` startActivity(`[Intent](http://developer.android.com/reference/android/content/Intent.html)` arg0) `                                                                                                                                                                                                                                                       | | ` void`                                                                                             | ` startActivity(`[Intent](http://developer.android.com/reference/android/content/Intent.html)` arg0, `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg1) `                                                                                                                                                                       | | ` void`                                                                                             | ` startActivityForResult(`[Intent](http://developer.android.com/reference/android/content/Intent.html)` arg0, int arg1) `                                                                                                                                                                                                                                    | | ` void`                                                                                             | ` startActivityForResult(`[Intent](http://developer.android.com/reference/android/content/Intent.html)` arg0, int arg1, `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg2) `                                                                                                                                                    | | ` void`                                                                                             | ` startIntentSenderForResult(`[IntentSender](http://developer.android.com/reference/android/content/IntentSender.html)` arg0, int arg1, `[Intent](http://developer.android.com/reference/android/content/Intent.html)` arg2, int arg3, int arg4, int arg5, `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg6) `                 | | ` void`                                                                                             | ` startPostponedEnterTransition() `                                                                                                                                                                                                                                                                                                                          | | ` `[String](http://developer.android.com/reference/java/lang/String.html)                           | ` toString() `                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                             | ` unregisterForContextMenu(`[View](http://developer.android.com/reference/android/view/View.html)` arg0) `                                                                                                                                                                                                                                                   | ||
| From class` `[java.lang.Object](http://developer.android.com/reference/java/lang/Object.html)` ` |------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------| | ` `[Object](http://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                               | | ` boolean`                                                                         | ` equals(`[Object](http://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                            | ` finalize() `                                                                            | | ` final `[Class](http://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                            | | ` int`                                                                             | ` hashCode() `                                                                            | | ` final void`                                                                      | ` notify() `                                                                              | | ` final void`                                                                      | ` notifyAll() `                                                                           | | ` `[String](http://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                            | | ` final void`                                                                      | ` wait(long arg0, int arg1) `                                                             | | ` final void`                                                                      | ` wait(long arg0) `                                                                       | | ` final void`                                                                      | ` wait() `                                                                                | ||
| From interface` `[android.content.ComponentCallbacks2](http://developer.android.com/reference/android/content/ComponentCallbacks2.html)` ` |------------------|----------------------------| | ` abstract void` | ` onTrimMemory(int arg0) ` | ||
| From interface` `[android.view.View.OnCreateContextMenuListener](http://developer.android.com/reference/android/view/View.OnCreateContextMenuListener.html)` ` |------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` onCreateContextMenu(`[ContextMenu](http://developer.android.com/reference/android/view/ContextMenu.html)` arg0, `[View](http://developer.android.com/reference/android/view/View.html)` arg1, `[ContextMenu.ContextMenuInfo](http://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo.html)` arg2) ` | ||
| From interface` `[android.content.ComponentCallbacks](http://developer.android.com/reference/android/content/ComponentCallbacks.html)` ` |------------------|-----------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` onConfigurationChanged(`[Configuration](http://developer.android.com/reference/android/content/res/Configuration.html)` arg0) ` | | ` abstract void` | ` onLowMemory() `                                                                                                                 | ||

## Constants

### EXPAND_DOWN

```
public static final int EXPAND_DOWN
```

<br />

<br />

Constant Value: 1 (0x00000001)  

### EXPAND_UP

```
public static final int EXPAND_UP
```

<br />

<br />

Constant Value: -1 (0xffffffff)  

### KEY_ICON_RESOURCE

```
public static final String KEY_ICON_RESOURCE
```

<br />

<br />

Constant Value: "CardFragment_icon"  

### KEY_TEXT

```
public static final String KEY_TEXT
```

<br />

<br />

Constant Value: "CardFragment_text"  

### KEY_TITLE

```
public static final String KEY_TITLE
```

<br />

<br />

Constant Value: "CardFragment_title"

## Public constructors

### CardFragment

```
public CardFragment ()
```

<br />

<br />

## Public methods

### create

```
public static CardFragment create (CharSequence title, 
                CharSequence text, 
                int iconRes)
```

Construct a new CardFragment using the default content layout, including and icon.

<br />

|                                     Parameters                                      ||
|-----------|--------------------------------------------------------------------------|
| `title`   | `CharSequence`: the card title displayed on the first line <br />        |
| `text`    | `CharSequence`: the card text displayed below the title <br />           |
| `iconRes` | `int`: a resourceId for an icon to be displayed next to the title <br /> |

|                                                              Returns                                                               ||
|---------------------------------------------------------------------------------------------------------|---------------------------|
| [CardFragment](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html) | a new CardFragment <br /> |

### create

```
public static CardFragment create (CharSequence title, 
                CharSequence description)
```

Construct a new CardFragment using the default content layout.

<br />

|                                    Parameters                                    ||
|---------------|-------------------------------------------------------------------|
| `title`       | `CharSequence`: the card title displayed on the first line <br /> |
| `description` | `CharSequence`: the card text displayed below the title <br />    |

|                                                              Returns                                                               ||
|---------------------------------------------------------------------------------------------------------|---------------------------|
| [CardFragment](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html) | a new CardFragment <br /> |

### getContentPadding

```
public Rect getContentPadding ()
```

Gets the padding between the inside card edge and the card content.

<br />

|                                      Returns                                      ||
|---------------------------------------------------------------------------|--------|
| [Rect](http://developer.android.com/reference/android/graphics/Rect.html) | <br /> |

### getContentPaddingBottom

```
public int getContentPaddingBottom ()
```

Gets the padding between the inside card's bottom edge and the card content.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

### getContentPaddingLeft

```
public int getContentPaddingLeft ()
```

Gets the padding between the inside card's left edge and the card content.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

### getContentPaddingRight

```
public int getContentPaddingRight ()
```

Gets the padding between the inside card's right edge and the card content.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

### getContentPaddingTop

```
public int getContentPaddingTop ()
```

Gets the padding between the inside card's top edge and the card content.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

### onActivityCreated

```
public void onActivityCreated (Bundle savedInstanceState)
```

<br />

<br />

|              Parameters               ||
|----------------------|-----------------|
| `savedInstanceState` | `Bundle` <br /> |

### onCreateContentView

```
public View onCreateContentView (LayoutInflater inflater, 
                ViewGroup container, 
                Bundle savedInstanceState)
```

Called to have subclasses instantiate their layout which is inserted within the card. Override this method to supply your own custom layout for the card content.

<br />

|                                                                                                               Parameters                                                                                                                ||
|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `inflater`           | `LayoutInflater`: The LayoutInflater object that can be used to inflate any views in the fragment <br />                                                                                                          |
| `container`          | `ViewGroup`: If non-null, this is the parent view that the fragment's UI should be attached to. The fragment should not add the view itself, but this can be used to generate the LayoutParams of the view <br /> |
| `savedInstanceState` | `Bundle`: If non-null, this fragment is being re-constructed from a previous saved state as given here <br />                                                                                                     |

|                                                           Returns                                                            ||
|-----------------------------------------------------------------------|-------------------------------------------------------|
| [View](http://developer.android.com/reference/android/view/View.html) | Return the View for the fragment's UI, or null <br /> |

### onCreateView

```
public final View onCreateView (LayoutInflater inflater, 
                ViewGroup container, 
                Bundle savedInstanceState)
```

<br />

<br />

|                  Parameters                   ||
|----------------------|-------------------------|
| `inflater`           | `LayoutInflater` <br /> |
| `container`          | `ViewGroup` <br />      |
| `savedInstanceState` | `Bundle` <br />         |

|                                    Returns                                    ||
|-----------------------------------------------------------------------|--------|
| [View](http://developer.android.com/reference/android/view/View.html) | <br /> |

### onDestroy

```
public void onDestroy ()
```

<br />

<br />

### scrollToBottom

```
public void scrollToBottom ()
```

Sets the card scroll position as far down as possible so the bottom edge is visible.

<br />

### scrollToTop

```
public void scrollToTop ()
```

Sets the card scroll position as far up as possible so the top edge is visible.

<br />

### setCardGravity

```
public void setCardGravity (int gravity)
```

Assigns vertical gravity to the card, which determines where it should float when the card and it's content are shorter than the page.

<br />

|                                                                                                            Parameters                                                                                                             ||
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `gravity` | `int`: a vertical gravity, either[Gravity.TOP](http://developer.android.com/reference/android/view/Gravity.html#TOP)or[Gravity.BOTTOM](http://developer.android.com/reference/android/view/Gravity.html#BOTTOM) <br /> |

### setCardMarginBottom

```
public void setCardMarginBottom (int bottom)
```

Sets the additional margin between the bottom edge of the card shadow, and the parent view.

<br />

|               Parameters               ||
|----------|------------------------------|
| `bottom` | `int`: the top margin <br /> |

### setCardMarginLeft

```
public void setCardMarginLeft (int left)
```

Sets the additional margin between the left edge of the card shadow, and the parent view.

<br />

|              Parameters              ||
|--------|------------------------------|
| `left` | `int`: the top margin <br /> |

### setCardMarginRight

```
public void setCardMarginRight (int right)
```

Sets the additional margin between the right edge of the card shadow, and the parent view.

<br />

|              Parameters               ||
|---------|------------------------------|
| `right` | `int`: the top margin <br /> |

### setCardMarginTop

```
public void setCardMarginTop (int top)
```

Sets the additional margin between the top edge of the card shadow, and the parent view.

<br />

|             Parameters              ||
|-------|------------------------------|
| `top` | `int`: the top margin <br /> |

### setCardMargins

```
public void setCardMargins (int left, 
                int top, 
                int right, 
                int bottom)
```

Sets the additional margin between the card shadow edge and the parent view.

<br />

|                Parameters                 ||
|----------|---------------------------------|
| `left`   | `int`: the left margin <br />   |
| `top`    | `int`: the top margin <br />    |
| `right`  | `int`: the right margin <br />  |
| `bottom` | `int`: the bottom margin <br /> |

### setContentPadding

```
public void setContentPadding (int left, 
                int top, 
                int right, 
                int bottom)
```

Sets padding between the inside card edge and the card content.

<br />

|                 Parameters                 ||
|----------|----------------------------------|
| `left`   | `int`: the left padding <br />   |
| `top`    | `int`: the top padding <br />    |
| `right`  | `int`: the right padding <br />  |
| `bottom` | `int`: the bottom padding <br /> |

### setContentPaddingBottom

```
public void setContentPaddingBottom (int bottomPadding)
```

Sets the padding between the inside card's bottom edge and the card content.

<br />

|                    Parameters                     ||
|-----------------|----------------------------------|
| `bottomPadding` | `int`: the bottom padding <br /> |

### setContentPaddingLeft

```
public void setContentPaddingLeft (int leftPadding)
```

Sets the padding between the inside card's left edge and the card content.

<br />

|                  Parameters                   ||
|---------------|--------------------------------|
| `leftPadding` | `int`: the left padding <br /> |

### setContentPaddingRight

```
public void setContentPaddingRight (int rightPadding)
```

Sets the padding between the inside card's right edge and the card content.

<br />

|                   Parameters                    ||
|----------------|---------------------------------|
| `rightPadding` | `int`: the right padding <br /> |

### setContentPaddingTop

```
public void setContentPaddingTop (int topPadding)
```

Sets the padding between the inside card's top edge and the card content.

<br />

|         Parameters         ||
|--------------|--------------|
| `topPadding` | `int` <br /> |

### setExpansionDirection

```
public void setExpansionDirection (int direction)
```

Adjusts which direction the card height will expand. This also determines which edge is rendered with a faded edge when more content is available by scrolling.

<br />

|                                                                                                                                        Parameters                                                                                                                                         ||
|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `direction` | `int`: a direction constant, either[EXPAND_UP](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#EXPAND_UP)or[EXPAND_DOWN](https://developer.android.com/reference/android/support/wearable/view/CardFragment.html#EXPAND_DOWN) <br /> |

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

<br />

|         Parameters          ||
|-----------|------------------|
| `enabled` | `boolean` <br /> |

### setExpansionFactor

```
public void setExpansionFactor (float factor)
```

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

<br />

|                                     Parameters                                     ||
|----------|--------------------------------------------------------------------------|
| `factor` | `float`: the vertical height multiplier to set the maximum height <br /> |