Summary: Constants | Inherited Constants | Ctors | Methods | Inherited Methods | [Expand All]

# CardFragment

`public class CardFragment`
`` `extends Fragment` ``

java.lang.Object
↳ | android.app.Fragment
| ↳ | android.support.wearable.view.CardFragment

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)`.

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)`
- `setExpansionEnabled(boolean)`
- `setExpansionDirection(int)`
- `setExpansionFactor(float)`

## Summary

### Constants
`int` | `EXPAND_DOWN`
`int` | `EXPAND_UP`
`String` | `KEY_ICON_RESOURCE`
`String` | `KEY_TEXT`
`String` | `KEY_TITLE`

### Inherited constants
From interface `android.content.ComponentCallbacks2`
`int` | `TRIM_MEMORY_BACKGROUND`
`int` | `TRIM_MEMORY_COMPLETE`
`int` | `TRIM_MEMORY_MODERATE`
`int` | `TRIM_MEMORY_RUNNING_CRITICAL`
`int` | `TRIM_MEMORY_RUNNING_LOW`
`int` | `TRIM_MEMORY_RUNNING_MODERATE`
`int` | `TRIM_MEMORY_UI_HIDDEN`

### Public constructors
`CardFragment()`

### Public methods
`static CardFragment` | `create(CharSequence title, CharSequence text, int iconRes)` Construct a new CardFragment using the default content layout, including and icon.
`static CardFragment` | `create(CharSequence title, CharSequence description)` Construct a new CardFragment using the default content layout.
`Rect` | `getContentPadding()` Gets the padding between the inside card edge and the card content.
`int` | `getContentPaddingBottom()` Gets the padding between the inside card's bottom edge and the card content.
`int` | `getContentPaddingLeft()` Gets the padding between the inside card's left edge and the card content.
`int` | `getContentPaddingRight()` Gets the padding between the inside card's right edge and the card content.
`int` | `getContentPaddingTop()` Gets the padding between the inside card's top edge and the card content.
`void` | `onActivityCreated(Bundle savedInstanceState)`
`View` | `onCreateContentView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)` Called to have subclasses instantiate their layout which is inserted within the card.
`final View` | `onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)`
`void` | `onDestroy()`
`void` | `scrollToBottom()` Sets the card scroll position as far down as possible so the bottom edge is visible.
`void` | `scrollToTop()` Sets the card scroll position as far up as possible so the top edge is visible.
`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.
`void` | `setCardMarginBottom(int bottom)` Sets the additional margin between the bottom edge of the card shadow, and the parent view.
`void` | `setCardMarginLeft(int left)` Sets the additional margin between the left edge of the card shadow, and the parent view.
`void` | `setCardMarginRight(int right)` Sets the additional margin between the right edge of the card shadow, and the parent view.
`void` | `setCardMarginTop(int top)` Sets the additional margin between the top edge of the card shadow, and the parent view.
`void` | `setCardMargins(int left, int top, int right, int bottom)` Sets the additional margin between the card shadow edge and the parent view.
`void` | `setContentPadding(int left, int top, int right, int bottom)` Sets padding between the inside card edge and the card content.
`void` | `setContentPaddingBottom(int bottomPadding)` Sets the padding between the inside card's bottom edge and the card content.
`void` | `setContentPaddingLeft(int leftPadding)` Sets the padding between the inside card's left edge and the card content.
`void` | `setContentPaddingRight(int rightPadding)` Sets the padding between the inside card's right edge and the card content.
`void` | `setContentPaddingTop(int topPadding)` Sets the padding between the inside card's top edge and the card content.
`void` | `setExpansionDirection(int direction)` Adjusts which direction the card height will expand.
`void` | `setExpansionEnabled(boolean enabled)` Enables support contents which maybe be larger than the card's container.
`void` | `setExpansionFactor(float factor)` Sets the allowed maximum height of the card as a multiple of the parent height.

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

## Constants

### EXPAND_DOWN

    int EXPAND_DOWN

Constant Value: 1 (0x00000001)

### EXPAND_UP

    int EXPAND_UP

Constant Value: -1 (0xffffffff)

### KEY_ICON_RESOURCE

    String KEY_ICON_RESOURCE

Constant Value: "CardFragment_icon"

### KEY_TEXT

    String KEY_TEXT

Constant Value: "CardFragment_text"

### KEY_TITLE

    String KEY_TITLE

Constant Value: "CardFragment_title"

## Public constructors

### CardFragment

    CardFragment ()

## Public methods

### create

    CardFragment create (CharSequence title,
                    CharSequence text,
                    int iconRes)

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

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

Returns
`CardFragment` | a new CardFragment

### create

    CardFragment create (CharSequence title,
                    CharSequence description)

Construct a new CardFragment using the default content layout.

Parameters
`title` | `CharSequence`: the card title displayed on the first line
`description` | `CharSequence`: the card text displayed below the title

Returns
`CardFragment` | a new CardFragment

### getContentPadding

    Rect getContentPadding ()

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

Returns
`Rect` |

### getContentPaddingBottom

    int getContentPaddingBottom ()

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

Returns
`int` |

### getContentPaddingLeft

    int getContentPaddingLeft ()

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

Returns
`int` |

### getContentPaddingRight

    int getContentPaddingRight ()

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

Returns
`int` |

### getContentPaddingTop

    int getContentPaddingTop ()

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

Returns
`int` |

### onActivityCreated

    void onActivityCreated (Bundle savedInstanceState)

Parameters
`savedInstanceState` | `Bundle`

### onCreateContentView

    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.

Parameters
`inflater` | `LayoutInflater`: The LayoutInflater object that can be used to inflate any views in the fragment
`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
`savedInstanceState` | `Bundle`: If non-null, this fragment is being re-constructed from a previous saved state as given here

Returns
`View` | Return the View for the fragment's UI, or null

### onCreateView

    View onCreateView (LayoutInflater inflater,
                    ViewGroup container,
                    Bundle savedInstanceState)

Parameters
`inflater` | `LayoutInflater`
`container` | `ViewGroup`
`savedInstanceState` | `Bundle`

Returns
`View` |

### onDestroy

    void onDestroy ()

### scrollToBottom

    void scrollToBottom ()

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

### scrollToTop

    void scrollToTop ()

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

### setCardGravity

    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.

Parameters
`gravity` | `int`: a vertical gravity, either `TOP` or `BOTTOM`

### setCardMarginBottom

    void setCardMarginBottom (int bottom)

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

Parameters
`bottom` | `int`: the top margin

### setCardMarginLeft

    void setCardMarginLeft (int left)

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

Parameters
`left` | `int`: the top margin

### setCardMarginRight

    void setCardMarginRight (int right)

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

Parameters
`right` | `int`: the top margin

### setCardMarginTop

    void setCardMarginTop (int top)

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

Parameters
`top` | `int`: the top margin

### setCardMargins

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

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

Parameters
`left` | `int`: the left margin
`top` | `int`: the top margin
`right` | `int`: the right margin
`bottom` | `int`: the bottom margin

### setContentPadding

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

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

Parameters
`left` | `int`: the left padding
`top` | `int`: the top padding
`right` | `int`: the right padding
`bottom` | `int`: the bottom padding

### setContentPaddingBottom

    void setContentPaddingBottom (int bottomPadding)

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

Parameters
`bottomPadding` | `int`: the bottom padding

### setContentPaddingLeft

    void setContentPaddingLeft (int leftPadding)

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

Parameters
`leftPadding` | `int`: the left padding

### setContentPaddingRight

    void setContentPaddingRight (int rightPadding)

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

Parameters
`rightPadding` | `int`: the right padding

### setContentPaddingTop

    void setContentPaddingTop (int topPadding)

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

Parameters
`topPadding` | `int`

### setExpansionDirection

    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.

Parameters
`direction` | `int`: a direction constant, either `EXPAND_UP` or `EXPAND_DOWN`

### setExpansionEnabled

    void setExpansionEnabled (boolean enabled)

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

Parameters
`enabled` | `boolean`

### setExpansionFactor

    void setExpansionFactor (float 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.

Parameters
`factor` | `float`: the vertical height multiplier to set the maximum height

- ## Interfaces

  - ActionChooserView.ActionChooserListener
  - DelayedConfirmationView.DelayedConfirmationListener
  - GridPageOptions
  - GridPageOptions.BackgroundListener
  - GridViewPager.OnAdapterChangeListener
  - GridViewPager.OnPageChangeListener
  - WatchViewStub.OnLayoutInflatedListener
  - WearableListView.ClickListener
  - WearableListView.OnCenterProximityListener
  - WearableListView.OnCentralPositionChangedListener
  - WearableListView.OnScrollListener

- ## Classes

  - ActionChooserView
  - ActionLabel
  - ActionPage
  - BoxInsetLayout
  - BoxInsetLayout.LayoutParams
  - CardFragment
  - CardFrame
  - CardScrollView
  - CircledImageView
  - CircularButton
  - CrossfadeDrawable
  - DelayedConfirmationView
  - DismissOverlayView
  - DotsPageIndicator
  - FragmentGridPagerAdapter
  - GridPagerAdapter
  - GridViewPager
  - GridViewPager.LayoutParams
  - ProgressSpinner
  - SimpleAnimatorListener
  - WatchViewStub
  - WearableFrameLayout
  - WearableFrameLayout.LayoutParams
  - WearableListView
  - WearableListView.Adapter
  - WearableListView.ViewHolder