Android.Views Namespace

Remarks

Provides classes that expose basic user interface classes that handle screen layout and interaction with the user.

Classes

TypeReason
AbsSavedStateA Android.OS.Parcelable implementation that should be used by inheritance hierarchies to ensure the state of all classes along the chain is saved.
AbsSavedState+InterfaceConstsDocumentation for this section has not yet been entered.
AccessibilityLiveRegionEnumerates values returned by several types.
ActionModeRepresents a contextual mode of the user interface.
ActionMode+ICallbackCallback interface for action modes.
ActionProviderAn ActionProvider defines rich menu interaction in a single component.
ActionProvider+IVisibilityListenerListens to changes in visibility as reported by Android.Views.ActionProvider.RefreshVisibility.
ActionProvider+VisibilityEventArgsProvides data for the Android.Views.ActionProvider.Visibility event.
AxisEnumerates values returned by several types and taken as a parameter of several types.
ChoreographerCoordinates the timing of animations, input and drawing.
Choreographer+IFrameCallbackImplement this interface to receive a callback when a new display frame is being rendered.
ContextThemeWrapperA ContextWrapper that allows you to modify the theme from what is in the wrapped context.
DescendantFocusabilityEnumerates values returned by several types.
DisplayProvides information about the size and density of a logical display.
DisplayFlagsEnumerates values returned by several types and taken as a parameter of the Android.Media.Projection.MediaProjection.CreateVirtualDisplay member.
DisplayStateEnumerates values returned by several types.
DragActionEnumerates values returned by several types.
DragEventRepresents an event that is sent out by the system at various times during a drag and drop operation.
DragEvent+InterfaceConstsDocumentation for this section has not yet been entered.
DrawingCacheQualityEnumerates values returned by several types.
EdgeEnumerates values returned by several types and taken as a parameter of several types.
FeedbackConstantsEnumerates values returned by the Android.Views.FeedbackConstants.KeyboardTap, Android.Views.FeedbackConstants.LongPress, and Android.Views.FeedbackConstants.VirtualKey members and taken as a parameter of the Android.Views.View.PerformHapticFeedback, and Android.Views.View.PerformHapticFeedback members.
FeedbackFlagsEnumerates values returned by the Android.Views.FeedbackFlags.IgnoreGlobalSetting, and Android.Views.FeedbackFlags.IgnoreViewSetting members and taken as a parameter of the Android.Views.View.PerformHapticFeedback member.
FindViewsWithEnumerates values returned by the Android.Views.FindViewsWith.ContentDescription, Android.Views.FindViewsWith.Text, and Android.Views.View.FindViewsWithContentDescription members and taken as a parameter of the Android.Views.View.FindViewsWithText, and Android.Views.View.FindViewsWithText members.
FocusablesFlagsEnumerates values returned by the Android.Views.FocusablesFlags.All, and Android.Views.FocusablesFlags.TouchMode members and taken as a parameter of the Android.Views.View.AddFocusables member.
FocusFinderThe algorithm used for finding the next focusable view in a given direction from a view that currently has focus.
FocusSearchDirection
FrameStatsThis is the base class for frame statistics.
GestureDetectorDetects various gestures and events using the supplied Android.Views.MotionEvents.
GestureDetector+DoubleTapEventArgsProvides data for the Android.Views.GestureDetector.DoubleTap event.
GestureDetector+DoubleTapEventEventArgsProvides data for the Android.Views.GestureDetector.DoubleTapEvent event.
GestureDetector+DownEventArgsDocumentation for this section has not yet been entered.
GestureDetector+FlingEventArgsDocumentation for this section has not yet been entered.
GestureDetector+IOnDoubleTapListenerThe listener that is used to notify when a double-tap or a confirmed single-tap occur.
GestureDetector+IOnGestureListenerThe listener that is used to notify when gestures occur.
GestureDetector+LongPressEventArgsDocumentation for this section has not yet been entered.
GestureDetector+ScrollEventArgsDocumentation for this section has not yet been entered.
GestureDetector+ShowPressEventArgsDocumentation for this section has not yet been entered.
GestureDetector+SimpleOnGestureListenerA convenience class to extend when you only want to listen for a subset of all the gestures.
GestureDetector+SingleTapConfirmedEventArgsProvides data for the Android.Views.GestureDetector.SingleTapConfirmed event.
GestureDetector+SingleTapUpEventArgsDocumentation for this section has not yet been entered.
GravityStandard constants and tools for placing an object within a potentially larger container.
GravityFlagsEnumerates values returned by several types and taken as a parameter of several types.
HapticFeedbackConstantsConstants to be used to perform haptic feedback effects via Android.Views.View.PerformHapticFeedback(Android.Views.FeedbackConstants)
ICollapsibleActionViewWhen a Android.Views.View implements this interface it will receive callbacks when expanded or collapsed as an action view alongside the optional, app-specified callbacks to Android.Views.IMenuItemOnActionExpandListener.
IContextMenuExtension of Android.Views.Menu for context menus providing functionality to modify the header of the context menu.
IContextMenuContextMenuInfoAdditional information regarding the creation of the context menu.
IContextMenuExtensionsDocumentation for this section has not yet been entered.
IMenuInterface for managing the items in a menu.
IMenuExtensionsDocumentation for this section has not yet been entered.
IMenuItemInterface for direct access to a previously created menu item.
IMenuItemExtensionsDocumentation for this section has not yet been entered.
IMenuItemOnActionExpandListenerInterface definition for a callback to be invoked when a menu item marked with Android.Views.IMenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW is expanded or collapsed.
IMenuItemOnMenuItemClickListenerInterface definition for a callback to be invoked when a menu item is clicked.
ImportantForAccessibilityEnumerates values returned by several types.
InflateExceptionThis exception is thrown by an inflater on error conditions.
InputDeviceDescribes the capabilities of a particular input device.
InputDevice+InterfaceConstsDocumentation for this section has not yet been entered.
InputDevice+MotionRangeProvides information about the range of values for a particular Android.Views.MotionEvent axis.
InputEventCommon base class for input events.
InputEvent+InterfaceConstsDocumentation for this section has not yet been entered.
InputKeyboardTypeEnumerates values returned by several types.
InputQueueAn input queue provides a mechanism for an application to receive incoming input events.
InputQueue+ICallbackInterface to receive notification of when an InputQueue is associated and dissociated with a thread.
InputSourceTypeEnumerates values returned by several types and taken as a parameter of several types.
ISubMenuSubclass of Android.Views.Menu for sub menus.
ISubMenuExtensionsDocumentation for this section has not yet been entered.
ISurfaceHolderAbstract interface to someone holding a display surface.
ISurfaceHolderCallbackA client may implement this interface to receive information about changes to the surface.
ISurfaceHolderCallback2Additional callbacks that can be received for Android.Views.ISurfaceHolderCallback.
IViewManagerInterface to let you add and remove child views to an Activity.
IViewParentDefines the responsibilities for a class that will be a parent of a View.
IWindowManagerThe interface that apps use to talk to the window manager.
KeyboardTypeEnumerates values returned by several types.
KeyCharacterMapDescribes the keys provided by a keyboard device and their associated labels.
KeyCharacterMap+InterfaceConstsDocumentation for this section has not yet been entered.
KeyCharacterMap+KeyDataDescribes the character mappings associated with a key.
KeyCharacterMap+UnavailableExceptionThrown by Android.Views.KeyCharacterMap.Load(int) when a key character map could not be loaded.
KeycodeEnumerates values returned by several types and taken as a parameter of several types.
KeyEventObject used to report key and button events.
KeyEvent+DispatcherStateUse with Android.Views.KeyEvent.Dispatch(Android.Views.KeyEvent.ICallback, Android.Views.KeyEvent.DispatcherState, Android.Views.KeyEvent.DispatcherState) for more advanced key dispatching, such as long presses.
KeyEvent+ICallbackDocumentation for this section has not yet been entered.
KeyEventActionsEnumerates values returned by several types and taken as a parameter of several methods of Android.Views.KeyEvent.
KeyEventFlagsEnumerates values returned by several types and taken as a parameter of several methods of Android.Views.KeyEvent.
KeyModifierBehaviorEnumerates values returned by the Android.Views.KeyCharacterMap.ModifierBehavior, Android.Views.KeyModifierBehavior.Chorded, and Android.Views.KeyModifierBehavior.ChordedOrToggled members.
LayerTypeEnumerates values returned by several types and taken as a parameter of the Android.Views.View.SetLayerType member.
LayoutDirectionEnumerates values returned by several types and taken as a parameter of the Android.Views.View.OnRtlPropertiesChanged, and Android.Views.ViewGroup.LayoutParams.ResolveLayoutDirection members.
LayoutInflaterInstantiates a layout XML file into its corresponding Android.Views.View objects.
LayoutInflater+IFactoryDocumentation for this section has not yet been entered.
LayoutInflater+IFactory2Documentation for this section has not yet been entered.
LayoutInflater+IFilterHook to allow clients of the LayoutInflater to restrict the set of Views that are allowed to be inflated.
MeasureSpecModeEnumerates values returned by several types and taken as a parameter of the Android.Views.View.MeasureSpec.MakeMeasureSpec member.
MemoryTypeEnumerates values returned by several types.
MenuInterface for managing the items in a menu.
MenuAppendFlagsEnumerates values returned by the Android.Views.MenuAppendFlags.AppendToGroup, and Android.Views.MenuAppendFlags.None members and taken as a parameter of the Android.Views.IMenu.AddIntentOptions member.
MenuCategoryEnumerates values returned by several methods of Android.Views.MenuCategory.
MenuConstsDocumentation for this section has not yet been entered.
MenuInflaterThis class is used to instantiate menu XML files into Menu objects.
MenuItemActionCollapseEventArgsDocumentation for this section has not yet been entered.
MenuItemActionExpandEventArgsDocumentation for this section has not yet been entered.
MenuItemOnMenuItemClickEventArgsDocumentation for this section has not yet been entered.
MenuPerformFlagsEnumerates values returned by the Android.Views.MenuPerformFlags.AlwaysPerformClose, Android.Views.MenuPerformFlags.None, and Android.Views.MenuPerformFlags.PerformNoClose members and taken as a parameter of several types.
MetaKeyStatesEnumerates values returned by several types and taken as a parameter of several types.
MotionEventObject used to report movement (mouse, pen, finger, trackball) events.
MotionEvent+PointerCoordsTransfer object for pointer coordinates.
MotionEvent+PointerPropertiesTransfer object for pointer properties.
MotionEventActionsEnumerates values returned by several types and taken as a parameter of several methods of Android.Views.MotionEvent.
MotionEventButtonStateEnumerates values returned by several types and taken as a parameter of the Android.Views.MotionEvent.IsButtonPressed, and Android.Views.MotionEvent.Obtain members.
MotionEventFlagsEnumerates values returned by several types and taken as a parameter of the Android.Views.MotionEvent.Obtain, and Android.Views.MotionEvent.Obtain members.
MotionEventToolTypeEnumerates values returned by several types.
MotionRangeEnumerates values returned by several types.
OrientationEventListenerHelper class for receiving notifications from the SensorManager when the orientation of the device has changed.
OrientationListenerHelper class for receiving notifications from the SensorManager when the orientation of the device has changed.
OverScrollModeEnumerates values returned by several types.
PersistentDrawingCachesEnumerates values returned by several types.
ScaleGestureDetectorDetects scaling transformation gestures using the supplied Android.Views.MotionEvents.
ScaleGestureDetector+IOnScaleGestureListenerThe listener for receiving notifications when gestures occur.
ScaleGestureDetector+ScaleBeginEventArgsDocumentation for this section has not yet been entered.
ScaleGestureDetector+ScaleEndEventArgsDocumentation for this section has not yet been entered.
ScaleGestureDetector+ScaleEventArgsDocumentation for this section has not yet been entered.
ScaleGestureDetector+SimpleOnScaleGestureListenerA convenience class to extend when you only want to listen for a subset of scaling-related events.
ScreenStateEnumerates values returned by several types and taken as a parameter of the Android.Views.View.OnScreenStateChanged member.
ScrollAxisEnumerates values returned by several types and taken as a parameter of several types.
ScrollbarPositionEnumerates values returned by several types.
ScrollbarStylesEnumerates values returned by several types.
ShowAsActionEnumerates values returned by several methods of Android.Views.ShowAsAction and taken as a parameter of the Android.Views.IMenuItem.SetShowAsAction, and Android.Views.IMenuItem.SetShowAsActionFlags members.
SoftInputEnumerates values returned by several types and taken as a parameter of the Android.Views.Window.SetSoftInputMode member.
SoundEffectConstantsConstants to be used to play sound effects via Android.Views.View.PlaySoundEffect(Android.Views.SoundEffects)
SoundEffectsEnumerates values returned by several types and taken as a parameter of the Android.Views.View.PlaySoundEffect member.
StatusBarVisibilityEnumerates values returned by several types and taken as a parameter of the Android.Views.View.IOnSystemUiVisibilityChangeListener.OnSystemUiVisibilityChange, and Android.Views.View.SystemUiVisibilityChangeEventArgs..ctor members.
SurfaceHandle onto a raw buffer that is being managed by the screen compositor.
Surface+InterfaceConstsDocumentation for this section has not yet been entered.
Surface+OutOfResourcesExceptionException thrown when a surface couldn't be created or resized.
SurfaceHolderBadSurfaceTypeExceptionException that is thrown from Android.Views.ISurfaceHolder.LockCanvas when called on a Surface whose type is SURFACE_TYPE_PUSH_BUFFERS.
SurfaceOrientationEnumerates values returned by several types and taken as a parameter of the Android.Views.Surface.SetOrientation member.
SurfaceTypeEnumerates values returned by several methods of Android.Views.SurfaceType and taken as a parameter of the Android.Views.ISurfaceHolder.SetType member.
SurfaceViewProvides a dedicated drawing surface embedded inside of a view hierarchy.
SystemUiFlagsEnumerates values returned by several types and taken as a parameter of the Android.Views.View.DispatchSystemUiVisibilityChanged, Android.Views.View.DispatchWindowSystemUiVisiblityChanged, and Android.Views.View.OnWindowSystemUiVisibilityChanged members.
TextAlignmentEnumerates values returned by several types.
TextDirectionEnumerates values returned by several types.
TextureView

java Example

  public class LiveCameraActivity extends Activity implements TextureView.SurfaceTextureListener {
      private Camera mCamera;
      private TextureView mTextureView;

      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);

          mTextureView = new TextureView(this);
          mTextureView.setSurfaceTextureListener(this);

          setContentView(mTextureView);
      }

      public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
          mCamera = Camera.open();

          try {
              mCamera.setPreviewTexture(surface);
              mCamera.startPreview();
          } catch (IOException ioe) {
              // Something bad happened
          }
      }

      public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
          // Ignored, Camera does all the work for us
      }

      public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
          mCamera.stopPreview();
          mCamera.release();
          return true;
      }

      public void onSurfaceTextureUpdated(SurfaceTexture surface) {
          // Invoked every time there's a new Camera preview frame
      }
  }
 
TextureView+ISurfaceTextureListenerThis listener can be used to be notified when the surface texture associated with this texture view is available.
TextureView+SurfaceTextureAvailableEventArgsProvides data for the Android.Views.TextureView.SurfaceTextureAvailable event.
TextureView+SurfaceTextureDestroyedEventArgsProvides data for the Android.Views.TextureView.SurfaceTextureDestroyed event.
TextureView+SurfaceTextureSizeChangedEventArgsProvides data for the Android.Views.TextureView.SurfaceTextureSizeChanged event.
TextureView+SurfaceTextureUpdatedEventArgsProvides data for the Android.Views.TextureView.SurfaceTextureUpdated event.
TouchableRegionEnumerates values returned by several methods of Android.Views.TouchableRegion.
TouchDelegateHelper class to handle situations where you want a view to have a larger touch area than its actual view bounds.
VelocityTrackerHelper for tracking the velocity of touch events, for implementing flinging and other such gestures.
View

Developer Guides

For information about using this class to develop your application's user interface, read the User Interface developer guide.
View+AccessibilityDelegate

Developer Guides

java Example

 if (Build.VERSION.SDK_INT >= 14) {
     // If the API version is equal of higher than the version in
     // which onInitializeAccessibilityNodeInfo was introduced we
     // register a delegate with a customized implementation.
     View view = findViewById(R.id.view_id);
     view.setAccessibilityDelegate(new AccessibilityDelegate() {
         public void onInitializeAccessibilityNodeInfo(View host,
                 AccessibilityNodeInfo info) {
             // Let the default implementation populate the info.
             super.onInitializeAccessibilityNodeInfo(host, info);
             // Set some other information.
             info.setEnabled(host.isEnabled());
         }
     });
 }
 
View+ApplyWindowInsetsHandlerDocumentation for this section has not yet been entered.
View+BaseSavedStateBase class for derived classes that want to save and restore their own state in Android.Views.View.OnSaveInstanceState.
View+CreateContextMenuEventArgsProvides data for the Android.Views.View.ContextMenuCreated event.
View+DragEventArgsProvides data for the Android.Views.View.Drag event.
View+DragShadowBuilderCreates an image that the system displays during the drag and drop operation.
View+FocusChangeEventArgsProvides data for the Android.Views.View.FocusChange, and Android.Widget.SearchView.QueryTextFocusChange events.
View+GenericMotionEventArgsProvides data for the Android.Views.View.GenericMotion event.
View+HoverEventArgsProvides data for the Android.Views.View.Hover event.
View+IOnApplyWindowInsetsListenerDocumentation for this section has not yet been entered.
View+IOnAttachStateChangeListenerInterface definition for a callback to be invoked when this view is attached or detached from its window.
View+IOnClickListenerInterface definition for a callback to be invoked when a view is clicked.
View+IOnCreateContextMenuListenerInterface definition for a callback to be invoked when the context menu for this view is being built.
View+IOnDragListenerInterface definition for a callback to be invoked when a drag is being dispatched to this view.
View+IOnFocusChangeListenerInterface definition for a callback to be invoked when the focus state of a view changed.
View+IOnGenericMotionListenerInterface definition for a callback to be invoked when a generic motion event is dispatched to this view.
View+IOnHoverListenerInterface definition for a callback to be invoked when a hover event is dispatched to this view.
View+IOnKeyListenerInterface definition for a callback to be invoked when a hardware key event is dispatched to this view.
View+IOnLayoutChangeListenerInterface definition for a callback to be invoked when the layout bounds of a view changes due to layout processing.
View+IOnLongClickListenerInterface definition for a callback to be invoked when a view has been clicked and held.
View+IOnSystemUiVisibilityChangeListenerInterface definition for a callback to be invoked when the status bar changes visibility.
View+IOnTouchListenerInterface definition for a callback to be invoked when a touch event is dispatched to this view.
View+KeyEventArgsProvides data for the Android.Views.View.KeyPress event.
View+LayoutChangeEventArgsProvides data for the Android.Views.View.LayoutChange event.
View+LongClickEventArgsProvides data for the Android.Views.View.LongClick event.
View+MeasureSpecA MeasureSpec encapsulates the layout requirements passed from parent to child.
View+SystemUiVisibilityChangeEventArgsProvides data for the Android.Views.View.SystemUiVisibilityChange event.
View+TouchEventArgsProvides data for the Android.Views.View.Touch, and Android.Widget.PopupWindow.TouchIntercepted events.
View+ViewAttachedToWindowEventArgsProvides data for the Android.Views.View.ViewAttachedToWindow event.
View+ViewDetachedFromWindowEventArgsProvides data for the Android.Views.View.ViewDetachedFromWindow event.
ViewAnimationUtilsDefines common utilities for working with View's animations.
ViewConfigurationContains methods to standard constants used in the UI for timeouts, sizes, and distances.
ViewDebugVarious debugging/tracing tools related to Android.Views.View and the view hierarchy.
ViewDebug+CapturedViewPropertyThis annotation can be used to mark fields and methods to be dumped when the view is captured.
ViewDebug+ExportedPropertyThis annotation can be used to mark fields and methods to be dumped by the view server.
ViewDebug+FlagToStringDefines a mapping from a flag to a String.
ViewDebug+HierarchyTraceTypeDocumentation for this section has not yet been entered.
ViewDebug+IntToStringDefines a mapping from an int value to a String.
ViewDebug+RecyclerTraceTypeDocumentation for this section has not yet been entered.
ViewGroup

Developer Guides

java Example

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RemoteViews;

/**
 * Example of writing a custom layout manager.  This is a fairly full-featured
 * layout manager that is relatively general, handling all layout cases.  You
 * can simplify it for more specific cases.
 */
@RemoteViews.RemoteView
public class CustomLayout extends ViewGroup {
    /** The amount of space used by children in the left gutter. */
    private int mLeftWidth;

    /** The amount of space used by children in the right gutter. */
    private int mRightWidth;

    /** These are used for computing child frames based on their gravity. */
    private final Rect mTmpContainerRect = new Rect();
    private final Rect mTmpChildRect = new Rect();

    public CustomLayout(Context context) {
        super(context);
    }

    public CustomLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CustomLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    /**
     * Any layout manager that doesn't scroll will want this.
     */
    @Override
    public boolean shouldDelayChildPressedState() {
        return false;
    }

    /**
     * Ask all children to measure themselves and compute the measurement of this
     * layout based on the children.
     */
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int count = getChildCount();

        // These keep track of the space we are using on the left and right for
        // views positioned there; we need member variables so we can also use
        // these for layout later.
        mLeftWidth = 0;
        mRightWidth = 0;

        // Measurement will ultimately be computing these values.
        int maxHeight = 0;
        int maxWidth = 0;
        int childState = 0;

        // Iterate through all children, measuring them and computing our dimensions
        // from their size.
        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            if (child.getVisibility() != GONE) {
                // Measure the child.
                measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);

                // Update our size information based on the layout params.  Children
                // that asked to be positioned on the left or right go in those gutters.
                final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                if (lp.position == LayoutParams.POSITION_LEFT) {
                    mLeftWidth += Math.max(maxWidth,
                            child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
                } else if (lp.position == LayoutParams.POSITION_RIGHT) {
                    mRightWidth += Math.max(maxWidth,
                            child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
                } else {
                    maxWidth = Math.max(maxWidth,
                            child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
                }
                maxHeight = Math.max(maxHeight,
                        child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
                childState = combineMeasuredStates(childState, child.getMeasuredState());
            }
        }

        // Total width is the maximum width of all inner children plus the gutters.
        maxWidth += mLeftWidth + mRightWidth;

        // Check against our minimum height and width
        maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
        maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());

        // Report our final dimensions.
        setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, childState),
                resolveSizeAndState(maxHeight, heightMeasureSpec,
                        childState << MEASURED_HEIGHT_STATE_SHIFT));
    }

    /**
     * Position all children within this layout.
     */
    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        final int count = getChildCount();

        // These are the far left and right edges in which we are performing layout.
        int leftPos = getPaddingLeft();
        int rightPos = right - left - getPaddingRight();

        // This is the middle region inside of the gutter.
        final int middleLeft = leftPos + mLeftWidth;
        final int middleRight = rightPos - mRightWidth;

        // These are the top and bottom edges in which we are performing layout.
        final int parentTop = getPaddingTop();
        final int parentBottom = bottom - top - getPaddingBottom();

        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            if (child.getVisibility() != GONE) {
                final LayoutParams lp = (LayoutParams) child.getLayoutParams();

                final int width = child.getMeasuredWidth();
                final int height = child.getMeasuredHeight();

                // Compute the frame in which we are placing this child.
                if (lp.position == LayoutParams.POSITION_LEFT) {
                    mTmpContainerRect.left = leftPos + lp.leftMargin;
                    mTmpContainerRect.right = leftPos + width + lp.rightMargin;
                    leftPos = mTmpContainerRect.right;
                } else if (lp.position == LayoutParams.POSITION_RIGHT) {
                    mTmpContainerRect.right = rightPos - lp.rightMargin;
                    mTmpContainerRect.left = rightPos - width - lp.leftMargin;
                    rightPos = mTmpContainerRect.left;
                } else {
                    mTmpContainerRect.left = middleLeft + lp.leftMargin;
                    mTmpContainerRect.right = middleRight - lp.rightMargin;
                }
                mTmpContainerRect.top = parentTop + lp.topMargin;
                mTmpContainerRect.bottom = parentBottom - lp.bottomMargin;

                // Use the child's gravity and size to determine its final
                // frame within its container.
                Gravity.apply(lp.gravity, width, height, mTmpContainerRect, mTmpChildRect);

                // Place the child.
                child.layout(mTmpChildRect.left, mTmpChildRect.top,
                        mTmpChildRect.right, mTmpChildRect.bottom);
            }
        }
    }

    // ----------------------------------------------------------------------
    // The rest of the implementation is for custom per-child layout parameters.
    // If you do not need these (for example you are writing a layout manager
    // that does fixed positioning of its children), you can drop all of this.

    @Override
    public LayoutParams generateLayoutParams(AttributeSet attrs) {
        return new CustomLayout.LayoutParams(getContext(), attrs);
    }

    @Override
    protected LayoutParams generateDefaultLayoutParams() {
        return new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    }

    @Override
    protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
        return new LayoutParams(p);
    }

    @Override
    protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
        return p instanceof LayoutParams;
    }

    /**
     * Custom per-child layout information.
     */
    public static class LayoutParams extends MarginLayoutParams {
        /**
         * The gravity to apply with the View to which these layout parameters
         * are associated.
         */
        public int gravity = Gravity.TOP | Gravity.START;

        public static int POSITION_MIDDLE = 0;
        public static int POSITION_LEFT = 1;
        public static int POSITION_RIGHT = 2;

        public int position = POSITION_MIDDLE;

        public LayoutParams(Context c, AttributeSet attrs) {
            super(c, attrs);

            // Pull the layout param values from the layout XML during
            // inflation.  This is not needed if you don't care about
            // changing the layout behavior in XML.
            TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.CustomLayoutLP);
            gravity = a.getInt(R.styleable.CustomLayoutLP_android_layout_gravity, gravity);
            position = a.getInt(R.styleable.CustomLayoutLP_layout_position, position);
            a.recycle();
        }

        public LayoutParams(int width, int height) {
            super(width, height);
        }

        public LayoutParams(ViewGroup.LayoutParams source) {
            super(source);
        }
    }
}

xml Example

<declare-styleable name="CustomLayoutLP">
    <attr name="android:layout_gravity" />
    <attr name="layout_position">
        <enum name="middle" value="0" />
        <enum name="left" value="1" />
        <enum name="right" value="2" />
    </attr>
</declare-styleable>

xml Example

<com.example.android.apis.view.CustomLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res/com.example.android.apis"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <!-- put first view to left. -->
    <TextView
            android:background="@drawable/filled_box"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_position="left"
            android:layout_gravity="fill_vertical|center_horizontal"
            android:text="l1"/>

    <!-- stack second view to left. -->
    <TextView
            android:background="@drawable/filled_box"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_position="left"
            android:layout_gravity="fill_vertical|center_horizontal"
            android:text="l2"/>

    <!-- also put a view on the right. -->
    <TextView
            android:background="@drawable/filled_box"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_position="right"
            android:layout_gravity="fill_vertical|center_horizontal"
            android:text="r1"/>

    <!-- by default views go in the middle; use fill vertical gravity -->
    <TextView
            android:background="@drawable/green"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="fill_vertical|center_horizontal"
            android:text="fill-vert"/>

    <!-- by default views go in the middle; use fill horizontal gravity -->
    <TextView
            android:background="@drawable/green"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|fill_horizontal"
            android:text="fill-horiz"/>

    <!-- by default views go in the middle; use top-left gravity -->
    <TextView
            android:background="@drawable/blue"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top|left"
            android:text="top-left"/>

    <!-- by default views go in the middle; use center gravity -->
    <TextView
            android:background="@drawable/blue"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="center"/>

    <!-- by default views go in the middle; use bottom-right -->
    <TextView
            android:background="@drawable/blue"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:text="bottom-right"/>

</com.example.android.apis.view.CustomLayout>
ViewGroup+ChildViewAddedEventArgsProvides data for the Android.Views.ViewGroup.ChildViewAdded event.
ViewGroup+ChildViewRemovedEventArgsProvides data for the Android.Views.ViewGroup.ChildViewRemoved event.
ViewGroup+IOnHierarchyChangeListenerInterface definition for a callback to be invoked when the hierarchy within this view changed.
ViewGroup+LayoutParamsLayoutParams are used by views to tell their parents how they want to be laid out.
ViewGroup+MarginLayoutParamsPer-child layout information for layouts that support margins.
ViewGroupOverlayA group overlay is an extra layer that sits on top of a ViewGroup (the "host view") which is drawn after all other content in that view (including the view group's children).
ViewLayoutModeEnumerates values returned by several types.
ViewOutlineProviderInterface by which a View builds its Android.Graphics.Outline, used for shadow casting and clipping.
ViewOverlayAn overlay is an extra layer that sits on top of a View (the "host view") which is drawn after all other content in that view (including children, if the view is a ViewGroup).
ViewPropertyAnimatorThis class enables automatic and optimized animation of select properties on View objects.
ViewStatesEnumerates values returned by several types and taken as a parameter of several types.
ViewStubA ViewStub is an invisible, zero-sized View that can be used to lazily inflate layout resources at runtime.
ViewStub+InflateEventArgsProvides data for the Android.Views.ViewStub.InflateEvent event.
ViewStub+IOnInflateListenerListener used to receive a notification after a ViewStub has successfully inflated its layout resource.
ViewTreeObserverA view tree observer is used to register listeners that can be notified of global changes in the view tree.
ViewTreeObserver+GlobalFocusChangeEventArgsProvides data for the Android.Views.ViewTreeObserver.GlobalFocusChange event.
ViewTreeObserver+IOnDrawListenerInterface definition for a callback to be invoked when the view tree is about to be drawn.
ViewTreeObserver+IOnGlobalFocusChangeListenerInterface definition for a callback to be invoked when the focus state within the view tree changes.
ViewTreeObserver+IOnGlobalLayoutListenerInterface definition for a callback to be invoked when the global layout state or the visibility of views within the view tree changes.
ViewTreeObserver+IOnPreDrawListenerInterface definition for a callback to be invoked when the view tree is about to be drawn.
ViewTreeObserver+IOnScrollChangedListenerInterface definition for a callback to be invoked when something in the view tree has been scrolled.
ViewTreeObserver+IOnTouchModeChangeListenerInterface definition for a callback to be invoked when the touch mode changes.
ViewTreeObserver+IOnWindowAttachListenerInterface definition for a callback to be invoked when the view hierarchy is attached to and detached from its window.
ViewTreeObserver+IOnWindowFocusChangeListenerInterface definition for a callback to be invoked when the view hierarchy's window focus state changes.
ViewTreeObserver+PreDrawEventArgsProvides data for the Android.Views.ViewTreeObserver.PreDraw event.
ViewTreeObserver+TouchModeChangeEventArgsProvides data for the Android.Views.ViewTreeObserver.TouchModeChange event.
ViewTreeObserver+WindowFocusChangeEventArgsProvides data for the Android.Views.ViewTreeObserver.WindowFocusChange event.
WindowAbstract base class for a top-level window look and behavior policy.
Window+ICallbackAPI from a Window back to its caller.
WindowAnimationFrameStatsThis class contains window animation frame statistics.
WindowAnimationFrameStats+InterfaceConstsDocumentation for this section has not yet been entered.
WindowContentFrameStatsThis class contains window content frame statistics.
WindowContentFrameStats+InterfaceConstsDocumentation for this section has not yet been entered.
WindowFeaturesEnumerates values returned by several methods of Android.Views.WindowFeatures and taken as a parameter of several types.
WindowIdSafe identifier for a window.
WindowId+FocusObserverSubclass for observing changes to the focus state of an Android.Views.WindowId.
WindowId+InterfaceConstsDocumentation for this section has not yet been entered.
WindowInsetsDescribes a set of insets for window content.
WindowManagerBadTokenExceptionException that is thrown when trying to add view whose Android.Views.WindowManagerLayoutParamsAndroid.Views.WindowManagerLayoutParams.Token is invalid.
WindowManagerEventTypeEnumerates values returned by several types.
WindowManagerFlagsEnumerates values returned by several types and taken as a parameter of several types.
WindowManagerInvalidDisplayExceptionException that is thrown when calling Android.Views.IViewManager.AddView(Android.Views.View, .LayoutParams) to a secondary display that cannot be found.
WindowManagerLayoutParams [Android Documentation]
WindowManagerLayoutParams+InterfaceConstsDocumentation for this section has not yet been entered.
WindowManagerTypesEnumerates values returned by several types and taken as a parameter of several types.
WindowProgressEnumerates values returned by several types.
WindowRotationAnimationEnumerates values returned by several types.