Android Guides | Samples

Android.Views Namespace

Remarks

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

Classes

TypeReason
AbsSavedStateA Parcelable implementation that should be used by inheritance hierarchies to ensure the state of all classes along the chain is saved.
AbsSavedState+InterfaceConsts
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 ActionProvider.RefreshVisibility.
ActionProvider+VisibilityEventArgsProvides data for the 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 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+InterfaceConsts
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 FeedbackConstants.KeyboardTap, FeedbackConstants.LongPress, and FeedbackConstants.VirtualKey members and taken as a parameter of the View.PerformHapticFeedback, and View.PerformHapticFeedback members.
FeedbackFlagsEnumerates values returned by the FeedbackFlags.IgnoreGlobalSetting, and FeedbackFlags.IgnoreViewSetting members and taken as a parameter of the View.PerformHapticFeedback member.
FindViewsWithEnumerates values returned by the FindViewsWith.ContentDescription, FindViewsWith.Text, and View.FindViewsWithContentDescription members and taken as a parameter of the View.FindViewsWithText, and View.FindViewsWithText members.
FocusablesFlagsEnumerates values returned by the FocusablesFlags.All, and FocusablesFlags.TouchMode members and taken as a parameter of the 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 MotionEvents.
GestureDetector+DoubleTapEventArgsProvides data for the GestureDetector.DoubleTap event.
GestureDetector+DoubleTapEventEventArgsProvides data for the GestureDetector.DoubleTapEvent event.
GestureDetector+DownEventArgs
GestureDetector+FlingEventArgs
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+LongPressEventArgs
GestureDetector+ScrollEventArgs
GestureDetector+ShowPressEventArgs
GestureDetector+SimpleOnGestureListenerA convenience class to extend when you only want to listen for a subset of all the gestures.
GestureDetector+SingleTapConfirmedEventArgsProvides data for the GestureDetector.SingleTapConfirmed event.
GestureDetector+SingleTapUpEventArgs
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 View.PerformHapticFeedback(FeedbackConstants)
ICollapsibleActionViewWhen a View implements this interface it will receive callbacks when expanded or collapsed as an action view alongside the optional, app-specified callbacks to IMenuItemOnActionExpandListener.
IContextMenuExtension of Menu for context menus providing functionality to modify the header of the context menu.
IContextMenuContextMenuInfoAdditional information regarding the creation of the context menu.
IContextMenuExtensions
IMenuInterface for managing the items in a menu.
IMenuExtensions
IMenuItemInterface for direct access to a previously created menu item.
IMenuItemExtensions
IMenuItemOnActionExpandListenerInterface definition for a callback to be invoked when a menu item marked with MenuItemCompat.ShowsAsActionCollapseActionView 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+InterfaceConsts
InputDevice+MotionRangeProvides information about the range of values for a particular MotionEvent axis.
InputEventCommon base class for input events.
InputEvent+InterfaceConsts
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 Menu for sub menus.
ISubMenuExtensions
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 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+InterfaceConsts
KeyCharacterMap+KeyDataDescribes the character mappings associated with a key.
KeyCharacterMap+UnavailableExceptionThrown by KeyCharacterMap.Load(Int32) 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 KeyEvent.Dispatch(ICallback,DispatcherState,DispatcherState) for more advanced key dispatching, such as long presses.
KeyEvent+ICallback
KeyEventActionsEnumerates values returned by several types and taken as a parameter of several methods of KeyEvent.
KeyEventFlagsEnumerates values returned by several types and taken as a parameter of several methods of KeyEvent.
KeyModifierBehaviorEnumerates values returned by the KeyCharacterMap.ModifierBehavior, KeyModifierBehavior.Chorded, and KeyModifierBehavior.ChordedOrToggled members.
LayerTypeEnumerates values returned by several types and taken as a parameter of the View.SetLayerType member.
LayoutDirectionEnumerates values returned by several types and taken as a parameter of the View.OnRtlPropertiesChanged, and ViewGroup+LayoutParams.ResolveLayoutDirection members.
LayoutInflaterInstantiates a layout XML file into its corresponding View objects.
LayoutInflater+IFactory
LayoutInflater+IFactory2
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 View+MeasureSpec.MakeMeasureSpec member.
MemoryTypeEnumerates values returned by several types.
MenuInterface for managing the items in a menu.
MenuAppendFlagsEnumerates values returned by the MenuAppendFlags.AppendToGroup, and MenuAppendFlags.None members and taken as a parameter of the IMenu.AddIntentOptions member.
MenuCategoryEnumerates values returned by several methods of MenuCategory.
MenuConsts
MenuInflaterThis class is used to instantiate menu XML files into Menu objects.
MenuItemActionCollapseEventArgs
MenuItemActionExpandEventArgs
MenuItemOnMenuItemClickEventArgs
MenuPerformFlagsEnumerates values returned by the MenuPerformFlags.AlwaysPerformClose, MenuPerformFlags.None, and 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 MotionEvent.
MotionEventButtonStateEnumerates values returned by several types and taken as a parameter of the MotionEvent.IsButtonPressed, and MotionEvent.Obtain members.
MotionEventFlagsEnumerates values returned by several types and taken as a parameter of the MotionEvent.Obtain, and 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 MotionEvents.
ScaleGestureDetector+IOnScaleGestureListenerThe listener for receiving notifications when gestures occur.
ScaleGestureDetector+ScaleBeginEventArgs
ScaleGestureDetector+ScaleEndEventArgs
ScaleGestureDetector+ScaleEventArgs
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 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 ShowAsAction and taken as a parameter of the IMenuItem.SetShowAsAction, and IMenuItem.SetShowAsActionFlags members.
SoftInputEnumerates values returned by several types and taken as a parameter of the Window.SetSoftInputMode member.
SoundEffectConstantsConstants to be used to play sound effects via View.PlaySoundEffect(SoundEffects)
SoundEffectsEnumerates values returned by several types and taken as a parameter of the View.PlaySoundEffect member.
StatusBarVisibilityEnumerates values returned by several types and taken as a parameter of the View+IOnSystemUiVisibilityChangeListener.OnSystemUiVisibilityChange, and Android.Views.View.SystemUiVisibilityChangeEventArgs..ctor members.
SurfaceHandle onto a raw buffer that is being managed by the screen compositor.
Surface+InterfaceConsts
Surface+OutOfResourcesExceptionException thrown when a surface couldn't be created or resized.
SurfaceHolderBadSurfaceTypeExceptionException that is thrown from 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 Surface.SetOrientation member.
SurfaceTypeEnumerates values returned by several methods of SurfaceType and taken as a parameter of the 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 View.DispatchSystemUiVisibilityChanged, View.DispatchWindowSystemUiVisiblityChanged, and 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 TextureView.SurfaceTextureAvailable event.
TextureView+SurfaceTextureDestroyedEventArgsProvides data for the TextureView.SurfaceTextureDestroyed event.
TextureView+SurfaceTextureSizeChangedEventArgsProvides data for the TextureView.SurfaceTextureSizeChanged event.
TextureView+SurfaceTextureUpdatedEventArgsProvides data for the TextureView.SurfaceTextureUpdated event.
TouchableRegionEnumerates values returned by several methods of 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+ApplyWindowInsetsHandler
View+BaseSavedStateBase class for derived classes that want to save and restore their own state in View.OnSaveInstanceState.
View+CreateContextMenuEventArgsProvides data for the View.ContextMenuCreated event.
View+DragEventArgsProvides data for the View.Drag event.
View+DragShadowBuilderCreates an image that the system displays during the drag and drop operation.
View+FocusChangeEventArgsProvides data for the View.FocusChange, and SearchView.QueryTextFocusChange events.
View+GenericMotionEventArgsProvides data for the View.GenericMotion event.
View+HoverEventArgsProvides data for the View.Hover event.
View+IOnApplyWindowInsetsListener
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 View.KeyPress event.
View+LayoutChangeEventArgsProvides data for the View.LayoutChange event.
View+LongClickEventArgsProvides data for the View.LongClick event.
View+MeasureSpecA MeasureSpec encapsulates the layout requirements passed from parent to child.
View+SystemUiVisibilityChangeEventArgsProvides data for the View.SystemUiVisibilityChange event.
View+TouchEventArgsProvides data for the View.Touch, and PopupWindow.TouchIntercepted events.
View+ViewAttachedToWindowEventArgsProvides data for the View.ViewAttachedToWindow event.
View+ViewDetachedFromWindowEventArgsProvides data for the 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 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+HierarchyTraceType
ViewDebug+IntToStringDefines a mapping from an int value to a String.
ViewDebug+RecyclerTraceType
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 ViewGroup.ChildViewAdded event.
ViewGroup+ChildViewRemovedEventArgsProvides data for the 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 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 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 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 ViewTreeObserver.PreDraw event.
ViewTreeObserver+TouchModeChangeEventArgsProvides data for the ViewTreeObserver.TouchModeChange event.
ViewTreeObserver+WindowFocusChangeEventArgsProvides data for the 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+InterfaceConsts
WindowContentFrameStatsThis class contains window content frame statistics.
WindowContentFrameStats+InterfaceConsts
WindowFeaturesEnumerates values returned by several methods of 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 WindowId.
WindowId+InterfaceConsts
WindowInsetsDescribes a set of insets for window content.
WindowManagerBadTokenExceptionException that is thrown when trying to add view whose WindowManagerLayoutParamsWindowManagerLayoutParams.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+InterfaceConsts
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.