FragmentContainerView


public final class FragmentContainerView extends FrameLayout


FragmentContainerView is a customized Layout designed specifically for Fragments. It extends FrameLayout, so it can reliably handle Fragment Transactions, and it also has additional features to coordinate with fragment behavior.

FragmentContainerView should be used as the container for Fragments, commonly set in the xml layout of an activity, e.g.:

<androidx.fragment.app.FragmentContainerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fragment_container_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.fragment.app.FragmentContainerView>

FragmentContainerView can also be used to add a Fragment by using the android:name attribute. FragmentContainerView will perform a one time operation that:

  1. Creates a new instance of the Fragment

  2. Calls Fragment.onInflate

  3. Executes a FragmentTransaction to add the Fragment to the appropriate FragmentManager

You can optionally include an android:tag which allows you to use FragmentManager.findFragmentByTag to retrieve the added Fragment.

<androidx.fragment.app.FragmentContainerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fragment_container_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.example.MyFragment"
android:tag="my_tag">
</androidx.fragment.app.FragmentContainerView>

FragmentContainerView should not be used as a replacement for other ViewGroups (FrameLayout, LinearLayout, etc) outside of Fragment use cases.

FragmentContainerView will only allow views returned by a Fragment's Fragment.onCreateView. Attempting to add any other view will result in an IllegalStateException.

Layout animations and transitions are disabled for FragmentContainerView for APIs above 17. Otherwise, Animations should be done through FragmentTransaction.setCustomAnimations. If animateLayoutChanges is set to true or setLayoutTransition is called directly an UnsupportedOperationException will be thrown.

Fragments using exit animations are drawn before all others for FragmentContainerView. This ensures that exiting Fragments do not appear on top of the view.

Summary

Public constructors

FragmentContainerView(
    @NonNull Context context,
    AttributeSet attrs,
    int defStyleAttr
)

Do not call this constructor directly.

Public methods

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

FragmentContainerView will only allow views returned by a Fragment's Fragment.onCreateView.

@NonNull WindowInsets

{@inheritDoc}

void
final @NonNull F
<F extends Fragment> getFragment()

This method grabs the Fragment whose view was most recently added to the container.

@NonNull WindowInsets
void
void
void
removeViewAt(int index)
void
void
removeViews(int start, int count)
void
removeViewsInLayout(int start, int count)
void

When called, this method throws a UnsupportedOperationException on APIs above 17.

void
void

Protected methods

void
boolean
drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime)

Inherited methods

From android.widget.FrameLayout
From android.view.View
void
addFocusables(@NonNull ArrayList<@NonNull View> views, int direction)
void
void
void
@NonNull ViewPropertyAnimator
void

This method is deprecated.

void
void
boolean
boolean
awakenScrollBars(int startDelay)
boolean
awakenScrollBars(int startDelay, boolean invalidate)
void
void

This method is deprecated.

void
buildDrawingCache(boolean autoScale)

This method is deprecated.

void
boolean
boolean
boolean
boolean
boolean
canScrollHorizontally(int direction)
boolean
canScrollVertically(int direction)
final void
void
final void
boolean
void
void
void
int
int
int
void
@NonNull WindowInsets
computeSystemWindowInsets(
    @NonNull WindowInsets in,
    @NonNull Rect outLocalInsets
)
int
int
int
@NonNull AccessibilityNodeInfo
void
void

This method is deprecated.

boolean
boolean
dispatchNestedFling(float velocityX, float velocityY, boolean consumed)
boolean
dispatchNestedPreFling(float velocityX, float velocityY)
boolean
dispatchNestedPrePerformAccessibilityAction(
    int action,
    @Nullable Bundle arguments
)
boolean
dispatchNestedPreScroll(
    int dx,
    int dy,
    @Nullable int[] consumed,
    @Nullable int[] offsetInWindow
)
boolean
dispatchNestedScroll(
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    @Nullable int[] offsetInWindow
)
boolean
void
draw(@NonNull Canvas canvas)
void
drawableHotspotChanged(float x, float y)
final @Nullable OnBackInvokedDispatcher
final @NonNull T
<T extends View> findViewById(int id)
final @NonNull T
<T extends View> findViewWithTag(@NonNull Object tag)
boolean

This method is deprecated.

@NonNull View
focusSearch(int direction)
void
forceHasOverlappingRendering(boolean hasOverlappingRendering)
void
void
generateDisplayHash(
    @NonNull String hashAlgorithm,
    @Nullable Rect bounds,
    @NonNull Executor executor,
    @NonNull DisplayHashResultCallback callback
)
@NonNull View.AccessibilityDelegate
int
@NonNull AccessibilityNodeProvider
@Nullable CharSequence
int
int
@Nullable String
@Nullable String
float
@ViewDebug.ExportedProperty(category = "drawing")
getAlpha()
@NonNull Animation
@Nullable Matrix
@NonNull IBinder
@NonNull int[]
@NonNull Map<@NonNull Integer, @NonNull Integer>
@Nullable String[]
final @NonNull AutofillId
int
@Nullable AutofillValue
@NonNull Drawable
@Nullable BlendMode
@Nullable ColorStateList
@Nullable PorterDuff.Mode
int
@ViewDebug.ExportedProperty(category = "layout")
getBaseline()
final int
float
int
float
@NonNull Rect
boolean
final boolean
final @Nullable ContentCaptureSession
@NonNull CharSequence
@ViewDebug.ExportedProperty(category = "accessibility")
getContentDescription()
final int
final @NonNull Context
@NonNull ContextMenu.ContextMenuInfo
final boolean
@NonNull Display
final @NonNull int[]
@NonNull Bitmap

This method is deprecated.

@NonNull Bitmap
getDrawingCache(boolean autoScale)

This method is deprecated.

int

This method is deprecated.

int

This method is deprecated.

void
long
float
@ViewDebug.ExportedProperty(category = "drawing")
getElevation()
int
boolean
boolean
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "NOT_FOCUSABLE"), @ViewDebug.IntToString(from = 1, to = "FOCUSABLE"), @ViewDebug.IntToString(from = 16, to = "FOCUSABLE_AUTO")], category = "focus")
getFocusable()
@NonNull ArrayList<@NonNull View>
getFocusables(int direction)
void
@NonNull Drawable
int
@Nullable BlendMode
@Nullable ColorStateList
@Nullable PorterDuff.Mode
float
final boolean
boolean
@NonNull Handler
float
float
float
float
int
@Nullable Runnable
final boolean
final int
@ViewDebug.ExportedProperty(category = "layout")
getHeight()
void
int
int
@Nullable Drawable
@Nullable Drawable
int
int
@ViewDebug.ExportedProperty(category = "accessibility", mapping = [@ViewDebug.IntToString(from = 0, to = "auto"), @ViewDebug.IntToString(from = 1, to = "yes"), @ViewDebug.IntToString(from = 2, to = "no"), @ViewDebug.IntToString(from = 4, to = "noHideDescendants")])
getImportantForAccessibility()
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "auto"), @ViewDebug.IntToString(from = 1, to = "yes"), @ViewDebug.IntToString(from = 2, to = "no"), @ViewDebug.IntToString(from = 4, to = "yesExcludeDescendants"), @ViewDebug.IntToString(from = 8, to = "noExcludeDescendants")])
getImportantForAutofill()
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "auto"), @ViewDebug.IntToString(from = 1, to = "yes"), @ViewDebug.IntToString(from = 2, to = "no"), @ViewDebug.IntToString(from = 4, to = "yesExcludeDescendants"), @ViewDebug.IntToString(from = 8, to = "noExcludeDescendants")])
getImportantForContentCapture()
boolean
@NonNull KeyEvent.DispatcherState
int
@ViewDebug.ExportedProperty(category = "accessibility")
getLabelFor()
int
@ViewDebug.ExportedProperty(category = "drawing", mapping = [@ViewDebug.IntToString(from = 0, to = "NONE"), @ViewDebug.IntToString(from = 1, to = "SOFTWARE"), @ViewDebug.IntToString(from = 2, to = "HARDWARE")])
getLayerType()
int
@ViewDebug.ExportedProperty(category = "layout", mapping = [@ViewDebug.IntToString(from = 0, to = "RESOLVED_DIRECTION_LTR"), @ViewDebug.IntToString(from = 1, to = "RESOLVED_DIRECTION_RTL")])
getLayoutDirection()
@NonNull ViewGroup.LayoutParams
@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_")
getLayoutParams()
final int
float
int
final boolean
void
getLocationInSurface(@NonNull int[] location)
void
getLocationInWindow(@NonNull int[] outLocation)
void
getLocationOnScreen(@NonNull int[] outLocation)
@NonNull Matrix
final int
final int
@ViewDebug.ExportedProperty(category = "measurement", flagMapping = [@ViewDebug.FlagToString(mask = -16777216, equals = 16777216, name = "MEASURED_STATE_TOO_SMALL")])
getMeasuredHeightAndState()
final int
final int
final int
@ViewDebug.ExportedProperty(category = "measurement", flagMapping = [@ViewDebug.FlagToString(mask = -16777216, equals = 16777216, name = "MEASURED_STATE_TOO_SMALL")])
getMeasuredWidthAndState()
int
int
int
int
int
int
int
int
@NonNull View.OnFocusChangeListener
int
@NonNull ViewOutlineProvider
int
int
int
int
int
int
int
int
final @NonNull ViewParent
@NonNull ViewParent
final @Nullable OutcomeReceiver<@NonNull GetCredentialResponse, @NonNull GetCredentialException>
final @Nullable GetCredentialRequest
float
@ViewDebug.ExportedProperty(category = "drawing")
getPivotX()
float
@ViewDebug.ExportedProperty(category = "drawing")
getPivotY()
@NonNull PointerIcon
final @NonNull List<@NonNull Rect>
@Nullable String[]
float
@NonNull Resources
final boolean
final int
float
int
@Nullable AttachedSurfaceControl
@NonNull View
@NonNull WindowInsets
float
@ViewDebug.ExportedProperty(category = "drawing")
getRotation()
float
@ViewDebug.ExportedProperty(category = "drawing")
getRotationX()
float
@ViewDebug.ExportedProperty(category = "drawing")
getRotationY()
float
@ViewDebug.ExportedProperty(category = "drawing")
getScaleX()
float
@ViewDebug.ExportedProperty(category = "drawing")
getScaleY()
int
int
int
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "INSIDE_OVERLAY"), @ViewDebug.IntToString(from = 16777216, to = "INSIDE_INSET"), @ViewDebug.IntToString(from = 33554432, to = "OUTSIDE_OVERLAY"), @ViewDebug.IntToString(from = 50331648, to = "OUTSIDE_INSET")])
getScrollBarStyle()
int
int
final int
final int
int
@ViewDebug.ExportedProperty(category = "drawing")
getSolidColor()
int
final @Nullable CharSequence
@ViewDebug.ExportedProperty(category = "accessibility")
getStateDescription()
@NonNull StateListAnimator
int
int
@Nullable CharSequence
@NonNull List<@NonNull Rect>
int

This method is deprecated.

@NonNull Object
@NonNull Object
getTag(int key)
int
@ViewDebug.ExportedProperty(category = "text", mapping = [@ViewDebug.IntToString(from = 0, to = "INHERIT"), @ViewDebug.IntToString(from = 1, to = "GRAVITY"), @ViewDebug.IntToString(from = 2, to = "TEXT_START"), @ViewDebug.IntToString(from = 3, to = "TEXT_END"), @ViewDebug.IntToString(from = 4, to = "CENTER"), @ViewDebug.IntToString(from = 5, to = "VIEW_START"), @ViewDebug.IntToString(from = 6, to = "VIEW_END")])
getTextAlignment()
int
@ViewDebug.ExportedProperty(category = "text", mapping = [@ViewDebug.IntToString(from = 0, to = "INHERIT"), @ViewDebug.IntToString(from = 1, to = "FIRST_STRONG"), @ViewDebug.IntToString(from = 2, to = "ANY_RTL"), @ViewDebug.IntToString(from = 3, to = "LTR"), @ViewDebug.IntToString(from = 4, to = "RTL"), @ViewDebug.IntToString(from = 5, to = "LOCALE"), @ViewDebug.IntToString(from = 6, to = "FIRST_STRONG_LTR"), @ViewDebug.IntToString(from = 7, to = "FIRST_STRONG_RTL")])
getTextDirection()
@Nullable CharSequence
final int
float
int
@NonNull TouchDelegate
@NonNull ArrayList<@NonNull View>
float
@NonNull String
float
float
float
long
int
int
@Nullable Drawable
@Nullable Drawable
int
@Nullable ViewTranslationResponse
@NonNull ViewTreeObserver
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "VISIBLE"), @ViewDebug.IntToString(from = 4, to = "INVISIBLE"), @ViewDebug.IntToString(from = 8, to = "GONE")])
getVisibility()
final int
@ViewDebug.ExportedProperty(category = "layout")
getWidth()
int
@NonNull WindowId
@Nullable WindowInsetsController
int

This method is deprecated.

@NonNull IBinder
int
void
float
@ViewDebug.ExportedProperty(category = "drawing")
getX()
float
@ViewDebug.ExportedProperty(category = "drawing")
getY()
float
@ViewDebug.ExportedProperty(category = "drawing")
getZ()
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
void
void

This method is deprecated.

void
invalidate(int l, int t, int r, int b)

This method is deprecated.

void
void
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean

This method is deprecated.

boolean
boolean
final boolean
@ViewDebug.ExportedProperty(category = "focus")
isFocusable()
final boolean
boolean
@ViewDebug.ExportedProperty(category = "focus")
isFocused()
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
final boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
@ViewDebug.ExportedProperty(category = "drawing")
isOpaque()
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
@NonNull View
keyboardNavigationClusterSearch(
    @NonNull View currentCluster,
    int direction
)
final void
measure(int widthMeasureSpec, int heightMeasureSpec)
void
offsetLeftAndRight(int offset)
void
offsetTopAndBottom(int offset)
void
void
void
boolean
boolean
void
void
@NonNull InputConnection
void
onCreateViewTranslationRequest(
    @NonNull int[] supportedFormats,
    @NonNull Consumer<@NonNull ViewTranslationRequest> requestsCollector
)
void
onCreateVirtualViewTranslationRequests(
    @NonNull long[] virtualIds,
    @NonNull int[] supportedFormats,
    @NonNull Consumer<@NonNull ViewTranslationRequest> requestsCollector
)
void
onDisplayHint(int hint)
boolean
void
void
final void
boolean
void
void
void
onFocusChanged(
    boolean gainFocus,
    int direction,
    @Nullable Rect previouslyFocusedRect
)
boolean
void
onHoverChanged(boolean hovered)
boolean
void
void
boolean
onKeyDown(int keyCode, @NonNull KeyEvent event)
boolean
onKeyLongPress(int keyCode, @NonNull KeyEvent event)
boolean
onKeyMultiple(int keyCode, int repeatCount, @NonNull KeyEvent event)
boolean
onKeyPreIme(int keyCode, @NonNull KeyEvent event)
boolean
onKeyShortcut(int keyCode, @NonNull KeyEvent event)
boolean
onKeyUp(int keyCode, @NonNull KeyEvent event)
void
onOverScrolled(
    int scrollX,
    int scrollY,
    boolean clampedX,
    boolean clampedY
)
void
onPointerCaptureChange(boolean hasCapture)
void
void
void
onProvideAutofillVirtualStructure(
    @NonNull ViewStructure structure,
    int flags
)
void
onProvideContentCaptureStructure(
    @NonNull ViewStructure structure,
    int flags
)
void
void
@Nullable ContentInfo
void
void
onRtlPropertiesChanged(int layoutDirection)
@Nullable Parcelable
void
onScreenStateChanged(int screenState)
void
onScrollCaptureSearch(
    @NonNull Rect localVisibleRect,
    @NonNull Point windowOffset,
    @NonNull Consumer<@NonNull ScrollCaptureTarget> targets
)
void
onScrollChanged(int l, int t, int oldl, int oldt)
boolean
onSetAlpha(int alpha)
void
onSizeChanged(int w, int h, int oldw, int oldh)
void
boolean
boolean
void
void
void
onVisibilityAggregated(boolean isVisible)
void
onVisibilityChanged(@NonNull View changedView, int visibility)
void
onWindowFocusChanged(boolean hasWindowFocus)
void

This method is deprecated.

void
onWindowVisibilityChanged(int visibility)
boolean
overScrollBy(
    int deltaX,
    int deltaY,
    int scrollX,
    int scrollY,
    int scrollRangeX,
    int scrollRangeY,
    int maxOverScrollX,
    int maxOverScrollY,
    boolean isTouchEvent
)
boolean
performAccessibilityAction(int action, @Nullable Bundle arguments)
boolean
boolean
boolean
performContextClick(float x, float y)
boolean
performHapticFeedback(int feedbackConstant)
boolean
performHapticFeedback(int feedbackConstant, int flags)
boolean
boolean
performLongClick(float x, float y)
@Nullable ContentInfo
void
playSoundEffect(int soundConstant)
boolean
boolean
postDelayed(@NonNull Runnable action, long delayMillis)
void
void
postInvalidate(int left, int top, int right, int bottom)
void
postInvalidateDelayed(long delayMilliseconds)
void
postInvalidateDelayed(
    long delayMilliseconds,
    int left,
    int top,
    int right,
    int bottom
)
void
void
postInvalidateOnAnimation(int left, int top, int right, int bottom)
void
void
postOnAnimationDelayed(@NonNull Runnable action, long delayMillis)
void
void
boolean
void
void
void
void
void
void

This method is deprecated.

final boolean
final boolean
requestFocus(int direction)
final boolean
void
void
boolean
boolean
requestRectangleOnScreen(@NonNull Rect rectangle, boolean immediate)
final void
final void
final @NonNull T
<T extends View> requireViewById(int id)
void
void
final void
saveAttributeDataForStyleable(
    @NonNull Context context,
    @NonNull int[] styleable,
    @Nullable AttributeSet attrs,
    @NonNull TypedArray t,
    int defStyleAttr,
    int defStyleRes
)
void
void
scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when)
void
scrollBy(int x, int y)
void
scrollTo(int x, int y)
void
sendAccessibilityEvent(int eventType)
void
void
setAccessibilityDataSensitive(int accessibilityDataSensitive)
void
void
setAccessibilityHeading(boolean isHeading)
void
void
void
void
void
setActivated(boolean activated)
void
setAllowClickWhenDisabled(boolean clickableWhenDisabled)
void
void
void
setAlpha(float alpha)
void
void
void
setAutoHandwritingEnabled(boolean enabled)
void
setAutofillHints(@Nullable String... autofillHints)
void
void
void
setBackgroundColor(int color)
void

This method is deprecated.

void
void
void
void
final void
setBottom(int bottom)
void
setCameraDistance(float distance)
void
setClickable(boolean clickable)
void
setClipBounds(@NonNull Rect clipBounds)
void
setClipToOutline(boolean clipToOutline)
void
void
final void
void
setContextClickable(boolean contextClickable)
void
setDefaultFocusHighlightEnabled(boolean defaultFocusHighlightEnabled)
void

This method is deprecated.

void
setDrawingCacheEnabled(boolean enabled)

This method is deprecated.

void

This method is deprecated.

void
void
setElevation(float elevation)
void
setEnabled(boolean enabled)
void
setFadingEdgeLength(int length)
void
void
setFitsSystemWindows(boolean fitSystemWindows)
void
setFocusable(boolean focusable)
void
setFocusable(int focusable)
void
setFocusableInTouchMode(boolean focusableInTouchMode)
void
setFocusedByDefault(boolean isFocusedByDefault)
void
setForceDarkAllowed(boolean allow)
void
void
void
void
void
setFrameContentVelocity(float pixelsPerSecond)
void
setHandwritingBoundsOffsets(
    float offsetLeft,
    float offsetTop,
    float offsetRight,
    float offsetBottom
)
void
void
void
setHapticFeedbackEnabled(boolean hapticFeedbackEnabled)
void
setHasTransientState(boolean hasTransientState)
void
setHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled)
void
setHorizontalScrollBarEnabled(boolean horizontalScrollBarEnabled)
void
void
void
setHovered(boolean hovered)
void
setId(int id)
void
void
void
void
setIsCredential(boolean isCredential)
void
setIsHandwritingDelegate(boolean isHandwritingDelegate)
void
setKeepScreenOn(boolean keepScreenOn)
void
setKeyboardNavigationCluster(boolean isCluster)
void
setLabelFor(int id)
void
void
setLayerType(int layerType, @Nullable Paint paint)
void
setLayoutDirection(int layoutDirection)
void
final void
setLeft(int left)
final void
setLeftTopRightBottom(int left, int top, int right, int bottom)
void
setLongClickable(boolean longClickable)
final void
setMeasuredDimension(int measuredWidth, int measuredHeight)
void
setMinimumHeight(int minHeight)
void
setMinimumWidth(int minWidth)
void
setNestedScrollingEnabled(boolean enabled)
void
setNextClusterForwardId(int nextClusterForwardId)
void
setNextFocusDownId(int nextFocusDownId)
void
setNextFocusForwardId(int nextFocusForwardId)
void
setNextFocusLeftId(int nextFocusLeftId)
void
setNextFocusRightId(int nextFocusRightId)
void
setNextFocusUpId(int nextFocusUpId)
void
void
void
void
void
void
void
void
void
void
void
setOnReceiveContentListener(
    @Nullable String[] mimeTypes,
    @Nullable OnReceiveContentListener listener
)
void
void

This method is deprecated.

void
void
void
void
void
setOverScrollMode(int overScrollMode)
void
setPadding(int left, int top, int right, int bottom)
void
setPaddingRelative(int start, int top, int end, int bottom)
void
void
setPivotX(float pivotX)
void
setPivotY(float pivotY)
void
final void
setPreferKeepClear(boolean preferKeepClear)
final void
void
setPressed(boolean pressed)
void
final void
setRevealOnFocusHint(boolean revealOnFocus)
final void
setRight(int right)
void
setRotation(float rotation)
void
setRotationX(float rotationX)
void
setRotationY(float rotationY)
void
setSaveEnabled(boolean enabled)
void
setSaveFromParentEnabled(boolean enabled)
void
setScaleX(float scaleX)
void
setScaleY(float scaleY)
void
setScreenReaderFocusable(boolean screenReaderFocusable)
void
setScrollBarDefaultDelayBeforeFade(
    int scrollBarDefaultDelayBeforeFade
)
void
setScrollBarFadeDuration(int scrollBarFadeDuration)
void
setScrollBarSize(int scrollBarSize)
void
setScrollBarStyle(int style)
final void
void
void
setScrollContainer(boolean isScrollContainer)
void
setScrollIndicators(int indicators)
void
setScrollIndicators(int indicators, int mask)
void
setScrollX(int value)
void
setScrollY(int value)
void
setScrollbarFadingEnabled(boolean fadeScrollbars)
void
setSelected(boolean selected)
void
setSoundEffectsEnabled(boolean soundEffectsEnabled)
void
void
void
setSupplementalDescription(
    @Nullable CharSequence supplementalDescription
)
void
void
setSystemUiVisibility(int visibility)

This method is deprecated.

void
void
setTag(int key, @NonNull Object tag)
void
setTextAlignment(int textAlignment)
void
setTextDirection(int textDirection)
void
final void
setTop(int top)
void
void
setTransitionAlpha(float alpha)
final void
setTransitionName(@NonNull String transitionName)
void
setTransitionVisibility(int visibility)
void
setTranslationX(float translationX)
void
setTranslationY(float translationY)
void
setTranslationZ(float translationZ)
void
setVerticalFadingEdgeEnabled(boolean verticalFadingEdgeEnabled)
void
setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled)
void
void
void
void
void
setVisibility(int visibility)
void
setWillNotCacheDrawing(boolean willNotCacheDrawing)

This method is deprecated.

void
setWillNotDraw(boolean willNotDraw)
void
setX(float x)
void
setY(float y)
void
setZ(float z)
boolean
boolean
showContextMenu(float x, float y)
@NonNull ActionMode
@NonNull ActionMode
void
final boolean
startDrag(
    @NonNull ClipData data,
    @NonNull View.DragShadowBuilder shadowBuilder,
    @NonNull Object myLocalState,
    int flags
)

This method is deprecated.

final boolean
startDragAndDrop(
    @NonNull ClipData data,
    @NonNull View.DragShadowBuilder shadowBuilder,
    @NonNull Object myLocalState,
    int flags
)
boolean
void
@NonNull String
void
void
void
void
final void
boolean
boolean

This method is deprecated.

boolean
@ViewDebug.ExportedProperty(category = "drawing")
willNotDraw()
From android.view.ViewGroup
void
void
void
addFocusables(@NonNull ArrayList<@NonNull View> p0, int p1, int p2)
void
boolean
void
void
void
addView(@NonNull View p0, int p1)
void
void
addView(@NonNull View p0, int p1, int p2)
boolean
addViewInLayout(
    @NonNull View p0,
    int p1,
    @NonNull ViewGroup.LayoutParams p2
)
boolean
addViewInLayout(
    @NonNull View p0,
    int p1,
    @NonNull ViewGroup.LayoutParams p2,
    boolean p3
)
void
attachLayoutAnimationParameters(
    @NonNull View p0,
    @NonNull ViewGroup.LayoutParams p1,
    int p2,
    int p3
)
void
attachViewToParent(
    @NonNull View p0,
    int p1,
    @NonNull ViewGroup.LayoutParams p2
)
void
boolean
void
void
void
void
void
void
void
debug(int p0)
void
void
void
void
detachViewsFromParent(int p0, int p1)
boolean
void
void
void
boolean
void
dispatchDrawableHotspotChanged(float p0, float p1)
void
void
boolean
boolean
boolean
boolean
boolean
boolean
void
void
void
void
void
void
void
void
dispatchSetPressed(boolean p0)
void
dispatchSetSelected(boolean p0)
void
void

This method is deprecated.

void
boolean
boolean
boolean
void
void
void
void
@NonNull WindowInsets
@NonNull WindowInsetsAnimation.Bounds
void

This method is deprecated.

void
void
@NonNull View
@Nullable OnBackInvokedDispatcher
void
findViewsWithText(
    @NonNull ArrayList<@NonNull View> p0,
    @NonNull CharSequence p1,
    int p2
)
@NonNull View
focusSearch(@NonNull View p0, int p1)
void
boolean
@NonNull View
getChildAt(int p0)
int
final int
int
getChildDrawingOrder(int p0, int p1)
boolean
boolean
boolean
boolean
int
@ViewDebug.ExportedProperty(category = "focus", mapping = [@ViewDebug.IntToString(from = 131072, to = "FOCUS_BEFORE_DESCENDANTS"), @ViewDebug.IntToString(from = 262144, to = "FOCUS_AFTER_DESCENDANTS"), @ViewDebug.IntToString(from = 393216, to = "FOCUS_BLOCK_DESCENDANTS")])
getDescendantFocusability()
@NonNull View
@NonNull LayoutAnimationController
@NonNull Animation.AnimationListener
int
@NonNull LayoutTransition
int
@NonNull ViewGroupOverlay
int
@ViewDebug.ExportedProperty(category = "drawing", mapping = [@ViewDebug.IntToString(from = 0, to = "NONE"), @ViewDebug.IntToString(from = 1, to = "ANIMATION"), @ViewDebug.IntToString(from = 2, to = "SCROLLING"), @ViewDebug.IntToString(from = 3, to = "ALL")])
getPersistentDrawingCache()

This method is deprecated. Deprecated in Java

boolean
boolean
boolean
int
final void

This method is deprecated. Deprecated in Java

@NonNull ViewParent

This method is deprecated. Deprecated in Java

boolean

This method is deprecated. Deprecated in Java

boolean

This method is deprecated. Deprecated in Java

boolean
boolean

This method is deprecated. Deprecated in Java

boolean
boolean
boolean
void
final void
layout(int p0, int p1, int p2, int p3)
void
measureChild(@NonNull View p0, int p1, int p2)
void
measureChildWithMargins(@NonNull View p0, int p1, int p2, int p3, int p4)
void
measureChildren(int p0, int p1)
void
notifySubtreeAccessibilityStateChanged(
    @NonNull View p0,
    @NonNull View p1,
    int p2
)
final void
final void
void
@NonNull int[]
void
void
boolean
boolean
boolean
onNestedFling(@NonNull View p0, float p1, float p2, boolean p3)
boolean
onNestedPreFling(@NonNull View p0, float p1, float p2)
boolean
void
onNestedPreScroll(@NonNull View p0, int p1, int p2, @NonNull int[] p3)
void
onNestedScroll(@NonNull View p0, int p1, int p2, int p3, int p4)
void
boolean
boolean
@NonNull PointerIcon
boolean
void
void
void
void
propagateRequestedFrameRate(float p0, boolean p1)
void
void
void
removeDetachedView(@NonNull View p0, boolean p1)
void
boolean
requestChildRectangleOnScreen(
    @NonNull View p0,
    @NonNull Rect p1,
    boolean p2
)
void
boolean
requestFocus(int p0, @NonNull Rect p1)
boolean
void
boolean
void
void
void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

void
void

This method is deprecated. Deprecated in Java

void
setClipChildren(boolean p0)
void
setClipToPadding(boolean p0)
void
void
void
void
setLayoutMode(int p0)
void
void
void

This method is deprecated. Deprecated in Java

void
void
void
void
setTransitionGroup(boolean p0)
void
boolean
boolean
showContextMenuForChild(@NonNull View p0, float p1, float p2)
@NonNull ActionMode
@NonNull ActionMode
startActionModeForChild(
    @NonNull View p0,
    @NonNull ActionMode.Callback p1,
    int p2
)
void
void
suppressLayout(boolean p0)
void

Public constructors

FragmentContainerView

Added in 1.2.0
public FragmentContainerView(@NonNull Context context)

FragmentContainerView

Added in 1.2.0
public FragmentContainerView(
    @NonNull Context context,
    AttributeSet attrs,
    int defStyleAttr
)

Do not call this constructor directly. Doing so will result in an UnsupportedOperationException.

Public methods

addView

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

FragmentContainerView will only allow views returned by a Fragment's Fragment.onCreateView. Attempting to add any other view will result in an IllegalStateException.

{@inheritDoc}

dispatchApplyWindowInsets

@RequiresApi(value = 20)
public @NonNull WindowInsets dispatchApplyWindowInsets(@NonNull WindowInsets insets)

{@inheritDoc}

The sys ui flags must be set to enable extending the layout into the window insets.

endViewTransition

public void endViewTransition(@NonNull View view)

getFragment

Added in 1.4.0
public final @NonNull F <F extends Fragment> getFragment()

This method grabs the Fragment whose view was most recently added to the container. This may used as an alternative to calling FragmentManager.findFragmentById and passing in the FragmentContainerView's id.

Returns
@NonNull F

The fragment if any exist, null otherwise.

onApplyWindowInsets

@RequiresApi(value = 20)
public @NonNull WindowInsets onApplyWindowInsets(@NonNull WindowInsets insets)

removeAllViewsInLayout

public void removeAllViewsInLayout()

removeView

public void removeView(@NonNull View view)

removeViewAt

public void removeViewAt(int index)

removeViewInLayout

public void removeViewInLayout(@NonNull View view)

removeViews

public void removeViews(int start, int count)

removeViewsInLayout

public void removeViewsInLayout(int start, int count)

setLayoutTransition

public void setLayoutTransition(LayoutTransition transition)

When called, this method throws a UnsupportedOperationException on APIs above 17. On APIs 17 and below, it calls FrameLayout.setLayoutTransition. This can be called either explicitly, or implicitly by setting animateLayoutChanges to true.

View animations and transitions are disabled for FragmentContainerView for APIs above 17. Use FragmentTransaction.setCustomAnimations and FragmentTransaction.setTransition.

ref android.R.styleable#ViewGroup_animateLayoutChanges

Parameters
LayoutTransition transition

The LayoutTransition object that will animated changes in layout. A value of null means no transition will run on layout changes.

setOnApplyWindowInsetsListener

public void setOnApplyWindowInsetsListener(
    View.OnApplyWindowInsetsListener listener
)

startViewTransition

public void startViewTransition(@NonNull View view)

Protected methods

dispatchDraw

protected void dispatchDraw(@NonNull Canvas canvas)

drawChild

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