Added in API level 3

HorizontalScrollView


open class HorizontalScrollView : FrameLayout
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.FrameLayout
   ↳ android.widget.HorizontalScrollView

Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. A HorizontalScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects. A child that is often used is a LinearLayout in a horizontal orientation, presenting a horizontal array of top-level items that the user can scroll through.

The TextView class also takes care of its own scrolling, so does not require a HorizontalScrollView, but using the two together is possible to achieve the effect of a text view within a larger container.

HorizontalScrollView only supports horizontal scrolling. For vertical scrolling, use either ScrollView or ListView.

Summary

XML attributes
android:fillViewport Defines whether the scrollview should stretch its content to fill the viewport.
Inherited XML attributes
Inherited constants
Public constructors

HorizontalScrollView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

HorizontalScrollView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Public methods
open Unit
addView(child: View!)

Adds a child view.

open Unit
addView(child: View!, params: ViewGroup.LayoutParams!)

Adds a child view with the specified layout parameters.

open Unit
addView(child: View!, index: Int)

Adds a child view.

open Unit
addView(child: View!, index: Int, params: ViewGroup.LayoutParams!)

Adds a child view with the specified layout parameters.

open Boolean
arrowScroll(direction: Int)

Handle scrolling in response to a left or right arrow click.

open Unit

Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary.

open Boolean

Dispatch a key event to the next view on the focus path.

open Unit
draw(canvas: Canvas)

Manually render this view (and all of its children) to the given Canvas.

open Boolean

You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the event had been dispatched to it by the view hierarchy.

open Unit
fling(velocityX: Int)

Fling the scroll view

open Boolean
fullScroll(direction: Int)

Handles scrolling in response to a "home/end" shortcut press.

open CharSequence!

Return the class name of this object to be used for accessibility purposes.

open Int

Returns the left edge effect color.

open Int

open Int

Returns the right edge effect color.

open Boolean

Indicates whether this HorizontalScrollView's content is stretched to fill the viewport.

open Boolean

open Boolean

Implement this method to handle generic motion events.

open Boolean

Implement this method to intercept all touch screen motion events.

open Boolean

Implement this method to handle pointer events.

open Boolean
pageScroll(direction: Int)

Handles scrolling in response to a "page up/down" shortcut press.

open Unit
requestChildFocus(child: View!, focused: View!)

Called when a child of this parent wants focus

open Boolean
requestChildRectangleOnScreen(child: View, rectangle: Rect!, immediate: Boolean)

Called when a child of this group wants a particular rectangle to be positioned onto the screen.

open Unit

Called when a child does not want this parent and its ancestors to intercept touch events with ViewGroup.onInterceptTouchEvent(MotionEvent).

open Unit

Call this when something has changed which has invalidated the layout of this view.

open Unit
scrollTo(x: Int, y: Int)

Set the scrolled position of your view.

open Unit

Sets the edge effect color for both left and right edge effects.

open Unit
setFillViewport(fillViewport: Boolean)

Indicates this HorizontalScrollView whether it should stretch its content width to fill the viewport or not.

open Unit

Sets the left edge effect color.

open Unit

Sets the right edge effect color.

open Unit
setSmoothScrollingEnabled(smoothScrollingEnabled: Boolean)

Set whether arrow scrolling will animate its transition.

open Boolean

Return true if the pressed state should be delayed for children or descendants of this ViewGroup.

Unit
smoothScrollBy(dx: Int, dy: Int)

Like View.scrollBy, but scroll smoothly instead of immediately.

Unit

Like scrollTo, but scroll smoothly instead of immediately.

Protected methods
open Int

Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range.

open Int

The scroll range of a scroll view is the overall width of all of its children.

open Int

Compute the amount to scroll in the X direction in order to get a rectangle completely on the screen (or, if taller than the screen, at least the first screen size chunk of it).

open Float

Returns the strength, or intensity, of the left faded edge.

open Float

Returns the strength, or intensity, of the right faded edge.

open Unit
measureChild(child: View!, parentWidthMeasureSpec: Int, parentHeightMeasureSpec: Int)

Ask one of the children of this view to measure itself, taking into account both the MeasureSpec requirements for this view and its padding.

open Unit
measureChildWithMargins(child: View!, parentWidthMeasureSpec: Int, widthUsed: Int, parentHeightMeasureSpec: Int, heightUsed: Int)

Ask one of the children of this view to measure itself, taking into account both the MeasureSpec requirements for this view and its padding and margins.

open Unit
onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int)

Called from layout when this view should assign a size and position to each of its children.

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

Measure the view and its content to determine the measured width and the measured height.

open Unit
onOverScrolled(scrollX: Int, scrollY: Int, clampedX: Boolean, clampedY: Boolean)

Called by overScrollBy(int,int,int,int,int,int,int,int,boolean) to respond to the results of an over-scroll operation.

open Boolean
onRequestFocusInDescendants(direction: Int, previouslyFocusedRect: Rect!)

When looking for focus in children of a scroll view, need to be a little more careful not to give focus to something that is scrolled off screen.

open Unit

Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState.

open Parcelable?

Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state.

open Unit
onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int)

This is called during layout when the size of this view has changed.

Inherited functions
Inherited properties

XML attributes

android:fillViewport

android:fillViewport
Defines whether the scrollview should stretch its content to fill the viewport.

May be a boolean value, such as "true" or "false".

Public constructors

HorizontalScrollView

Added in API level 3
HorizontalScrollView(context: Context!)

HorizontalScrollView

Added in API level 3
HorizontalScrollView(
    context: Context!,
    attrs: AttributeSet!)

HorizontalScrollView

Added in API level 3
HorizontalScrollView(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int)

HorizontalScrollView

Added in API level 21
HorizontalScrollView(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int)

Public methods

addView

Added in API level 3
open fun addView(child: View!): Unit

Adds a child view. If no layout parameters are already set on the child, the default parameters for this ViewGroup are set on the child.

Note: do not invoke this method from draw(android.graphics.Canvas), onDraw(android.graphics.Canvas), dispatchDraw(android.graphics.Canvas) or any related method.

Parameters
child View!: the child view to add

addView

Added in API level 3
open fun addView(
    child: View!,
    params: ViewGroup.LayoutParams!
): Unit

Adds a child view with the specified layout parameters.

Note: do not invoke this method from draw(android.graphics.Canvas), onDraw(android.graphics.Canvas), dispatchDraw(android.graphics.Canvas) or any related method.

Parameters
view The view to be added to this window.
params ViewGroup.LayoutParams!: the layout parameters to set on the child
child View!: the child view to add

addView

Added in API level 3
open fun addView(
    child: View!,
    index: Int
): Unit

Adds a child view. If no layout parameters are already set on the child, the default parameters for this ViewGroup are set on the child.

Note: do not invoke this method from draw(android.graphics.Canvas), onDraw(android.graphics.Canvas), dispatchDraw(android.graphics.Canvas) or any related method.

Parameters
child View!: the child view to add
index Int: the position at which to add the child

addView

Added in API level 3
open fun addView(
    child: View!,
    index: Int,
    params: ViewGroup.LayoutParams!
): Unit

Adds a child view with the specified layout parameters.

Note: do not invoke this method from draw(android.graphics.Canvas), onDraw(android.graphics.Canvas), dispatchDraw(android.graphics.Canvas) or any related method.

Parameters
child View!: the child view to add
index Int: the position at which to add the child or -1 to add last
params ViewGroup.LayoutParams!: the layout parameters to set on the child

arrowScroll

Added in API level 3
open fun arrowScroll(direction: Int): Boolean

Handle scrolling in response to a left or right arrow click.

Parameters
direction Int: The direction corresponding to the arrow key that was pressed
Return
Boolean True if we consumed the event, false otherwise

computeScroll

Added in API level 3
open fun computeScroll(): Unit

Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary. This will typically be done if the child is animating a scroll using a Scroller object.

dispatchKeyEvent

Added in API level 3
open fun dispatchKeyEvent(event: KeyEvent!): Boolean

Dispatch a key event to the next view on the focus path. This path runs from the top of the view tree down to the currently focused view. If this view has focus, it will dispatch to itself. Otherwise it will dispatch the next node down the focus path. This method also fires any key listeners.

Parameters
event KeyEvent!: The key event to be dispatched.
Return
Boolean True if the event was handled, false otherwise.

draw

Added in API level 3
open fun draw(canvas: Canvas): Unit

Manually render this view (and all of its children) to the given Canvas. The view must have already done a full layout before this function is called. When implementing a view, implement onDraw(android.graphics.Canvas) instead of overriding this method. If you do need to override this method, call the superclass version.
If you override this method you must call through to the superclass implementation.

Parameters
canvas Canvas: The Canvas to which the View is rendered.
This value cannot be null.

executeKeyEvent

Added in API level 3
open fun executeKeyEvent(event: KeyEvent!): Boolean

You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the event had been dispatched to it by the view hierarchy.

Parameters
event KeyEvent!: The key event to execute.
Return
Boolean Return true if the event was handled, else false.

fling

Added in API level 3
open fun fling(velocityX: Int): Unit

Fling the scroll view

Parameters
velocityX Int: The initial velocity in the X direction. Positive numbers mean that the finger/cursor is moving down the screen, which means we want to scroll towards the left.

fullScroll

Added in API level 3
open fun fullScroll(direction: Int): Boolean

Handles scrolling in response to a "home/end" shortcut press. This method will scroll the view to the left or right and give the focus to the leftmost/rightmost component in the new visible area. If no component is a good candidate for focus, this scrollview reclaims the focus.

Parameters
direction Int: the scroll direction: android.view.View#FOCUS_LEFT to go the left of the view or android.view.View#FOCUS_RIGHT to go the right
Return
Boolean true if the key event is consumed by this method, false otherwise

getAccessibilityClassName

Added in API level 23
open fun getAccessibilityClassName(): CharSequence!

Return the class name of this object to be used for accessibility purposes. Subclasses should only override this if they are implementing something that should be seen as a completely new class of view when used by accessibility, unrelated to the class it is deriving from. This is used to fill in AccessibilityNodeInfo.setClassName.

getLeftEdgeEffectColor

Added in API level 29
open fun getLeftEdgeEffectColor(): Int

Returns the left edge effect color.

Return
Int The left edge effect color.

getMaxScrollAmount

Added in API level 3
open fun getMaxScrollAmount(): Int
Return
Int The maximum amount this scroll view will scroll in response to an arrow event.

getRightEdgeEffectColor

Added in API level 29
open fun getRightEdgeEffectColor(): Int

Returns the right edge effect color.

Return
Int The right edge effect color.

isFillViewport

Added in API level 3
open fun isFillViewport(): Boolean

Indicates whether this HorizontalScrollView's content is stretched to fill the viewport.

Return
Boolean True if the content fills the viewport, false otherwise.

isSmoothScrollingEnabled

Added in API level 3
open fun isSmoothScrollingEnabled(): Boolean
Return
Boolean Whether arrow scrolling will animate its transition.

onGenericMotionEvent

Added in API level 12
open fun onGenericMotionEvent(event: MotionEvent!): Boolean

Implement this method to handle generic motion events.

Generic motion events describe joystick movements, hover events from mouse or stylus devices, trackpad touches, scroll wheel movements and other motion events not handled by onTouchEvent(android.view.MotionEvent) or onTrackballEvent(android.view.MotionEvent). The source of the motion event specifies the class of input that was received. Implementations of this method must examine the bits in the source before processing the event. The following code example shows how this is done.

Generic motion events with source class InputDevice.SOURCE_CLASS_POINTER are delivered to the view under the pointer. All other generic motion events are delivered to the focused view.

public boolean onGenericMotionEvent(MotionEvent event) {
      if (event.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) {
          if (event.getAction() == MotionEvent.ACTION_MOVE) {
              // process the joystick movement...
              return true;
          }
      }
      if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) {
          switch (event.getAction()) {
              case MotionEvent.ACTION_HOVER_MOVE:
                  // process the hover movement...
                  return true;
              case MotionEvent.ACTION_SCROLL:
                  // process the scroll wheel movement...
                  return true;
          }
      }
      return super.onGenericMotionEvent(event);
  }
Parameters
event MotionEvent!: The generic motion event being processed.
Return
Boolean True if the event was handled, false otherwise.

onInterceptTouchEvent

Added in API level 3
open fun onInterceptTouchEvent(ev: MotionEvent!): Boolean

Implement this method to intercept all touch screen motion events. This allows you to watch events as they are dispatched to your children, and take ownership of the current gesture at any point.

Using this function takes some care, as it has a fairly complicated interaction with View.onTouchEvent(MotionEvent), and using it requires implementing that method as well as this one in the correct way. Events will be received in the following order:

  1. You will receive the down event here.
  2. The down event will be handled either by a child of this view group, or given to your own onTouchEvent() method to handle; this means you should implement onTouchEvent() to return true, so you will continue to see the rest of the gesture (instead of looking for a parent view to handle it). Also, by returning true from onTouchEvent(), you will not receive any following events in onInterceptTouchEvent() and all touch processing must happen in onTouchEvent() like normal.
  3. For as long as you return false from this function, each following event (up to and including the final up) will be delivered first here and then to the target's onTouchEvent().
  4. If you return true from here, you will not receive any following events: the target view will receive the same event but with the action MotionEvent.ACTION_CANCEL, and all further events will be delivered to your onTouchEvent() method and no longer appear here.
Parameters
ev MotionEvent!: The motion event being dispatched down the hierarchy.
Return
Boolean Return true to steal motion events from the children and have them dispatched to this ViewGroup through onTouchEvent(). The current target will receive an ACTION_CANCEL event, and no further messages will be delivered here.

onTouchEvent

Added in API level 3
open fun onTouchEvent(ev: MotionEvent!): Boolean

Implement this method to handle pointer events.

This method is called to handle motion events where pointers are down on the view. For example, this could include touchscreen touches, stylus touches, or click-and-drag events from a mouse. However, it is not called for motion events that do not involve pointers being down, such as hover events or mouse scroll wheel movements.

If this method is used to detect click actions, it is recommended that the actions be performed by implementing and calling performClick(). This will ensure consistent system behavior, including:

  • obeying click sound preferences
  • dispatching OnClickListener calls
  • handling ACTION_CLICK when accessibility features are enabled
Parameters
event The motion event.
Return
Boolean True if the event was handled, false otherwise.

pageScroll

Added in API level 3
open fun pageScroll(direction: Int): Boolean

Handles scrolling in response to a "page up/down" shortcut press. This method will scroll the view by one page left or right and give the focus to the leftmost/rightmost component in the new visible area. If no component is a good candidate for focus, this scrollview reclaims the focus.

Parameters
direction Int: the scroll direction: android.view.View#FOCUS_LEFT to go one page left or android.view.View#FOCUS_RIGHT to go one page right
Return
Boolean true if the key event is consumed by this method, false otherwise

requestChildFocus

Added in API level 3
open fun requestChildFocus(
    child: View!,
    focused: View!
): Unit

Called when a child of this parent wants focus

Parameters
child View!: The child of this ViewParent that wants focus. This view will contain the focused view. It is not necessarily the view that actually has focus.
focused View!: The view that is a descendant of child that actually has focus

requestChildRectangleOnScreen

Added in API level 3
open fun requestChildRectangleOnScreen(
    child: View,
    rectangle: Rect!,
    immediate: Boolean
): Boolean

Called when a child of this group wants a particular rectangle to be positioned onto the screen. ViewGroups overriding this can trust that:

  • child will be a direct child of this group
  • rectangle will be in the child's content coordinates

ViewGroups overriding this should uphold the contract:

  • nothing will change if the rectangle is already visible
  • the view port will be scrolled only just enough to make the rectangle visible
Parameters
child View: The direct child making the request.
This value cannot be null.
rectangle Rect!: The rectangle in the child's coordinates the child wishes to be on the screen.
immediate Boolean: True to forbid animated or delayed scrolling, false otherwise
Return
Boolean Whether the group scrolled to handle the operation

requestDisallowInterceptTouchEvent

Added in API level 3
open fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean): Unit

Called when a child does not want this parent and its ancestors to intercept touch events with ViewGroup.onInterceptTouchEvent(MotionEvent).

This parent should pass this call onto its parents. This parent must obey this request for the duration of the touch (that is, only clear the flag after this parent has received an up or a cancel.

Parameters
disallowIntercept Boolean: True if the child does not want the parent to intercept touch events.

requestLayout

Added in API level 3
open fun requestLayout(): Unit

Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree. This should not be called while the view hierarchy is currently in a layout pass (isInLayout(). If layout is happening, the request may be honored at the end of the current layout pass (and then layout will run again) or after the current frame is drawn and the next layout occurs.

Subclasses which override this method should call the superclass method to handle possible request-during-layout errors correctly.

.
If you override this method you must call through to the superclass implementation.

scrollTo

Added in API level 3
open fun scrollTo(
    x: Int,
    y: Int
): Unit

Set the scrolled position of your view. This will cause a call to onScrollChanged(int,int,int,int) and the view will be invalidated.

This version also clamps the scrolling to the bounds of our child.

Parameters
x Int: the x position to scroll to
y Int: the y position to scroll to

setEdgeEffectColor

Added in API level 29
open fun setEdgeEffectColor(color: Int): Unit

Sets the edge effect color for both left and right edge effects.

Parameters
color Int: The color for the edge effects.

setFillViewport

Added in API level 3
open fun setFillViewport(fillViewport: Boolean): Unit

Indicates this HorizontalScrollView whether it should stretch its content width to fill the viewport or not.

Parameters
fillViewport Boolean: True to stretch the content's width to the viewport's boundaries, false otherwise.

setLeftEdgeEffectColor

Added in API level 29
open fun setLeftEdgeEffectColor(color: Int): Unit

Sets the left edge effect color.

Parameters
color Int: The color for the left edge effect.

setRightEdgeEffectColor

Added in API level 29
open fun setRightEdgeEffectColor(color: Int): Unit

Sets the right edge effect color.

Parameters
color Int: The color for the right edge effect.

setSmoothScrollingEnabled

Added in API level 3
open fun setSmoothScrollingEnabled(smoothScrollingEnabled: Boolean): Unit

Set whether arrow scrolling will animate its transition.

Parameters
smoothScrollingEnabled Boolean: whether arrow scrolling will animate its transition

shouldDelayChildPressedState

Added in API level 14
open fun shouldDelayChildPressedState(): Boolean

Return true if the pressed state should be delayed for children or descendants of this ViewGroup. Generally, this should be done for containers that can scroll, such as a List. This prevents the pressed state from appearing when the user is actually trying to scroll the content. The default implementation returns true for compatibility reasons. Subclasses that do not scroll should generally override this method and return false.

smoothScrollBy

Added in API level 3
fun smoothScrollBy(
    dx: Int,
    dy: Int
): Unit

Like View.scrollBy, but scroll smoothly instead of immediately.

Parameters
dx Int: the number of pixels to scroll by on the X axis
dy Int: the number of pixels to scroll by on the Y axis

smoothScrollTo

Added in API level 3
fun smoothScrollTo(
    x: Int,
    y: Int
): Unit

Like scrollTo, but scroll smoothly instead of immediately.

Parameters
x Int: the position where to scroll on the X axis
y Int: the position where to scroll on the Y axis

Protected methods

computeHorizontalScrollOffset

Added in API level 3
protected open fun computeHorizontalScrollOffset(): Int

Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range. This value is used to compute the position of the thumb within the scrollbar's track.

The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollRange() and computeHorizontalScrollExtent().

The default offset is the scroll offset of this view.

Return
Int the horizontal offset of the scrollbar's thumb

computeHorizontalScrollRange

Added in API level 3
protected open fun computeHorizontalScrollRange(): Int

The scroll range of a scroll view is the overall width of all of its children.

Return
Int the total horizontal range represented by the horizontal scrollbar

computeScrollDeltaToGetChildRectOnScreen

Added in API level 3
protected open fun computeScrollDeltaToGetChildRectOnScreen(rect: Rect!): Int

Compute the amount to scroll in the X direction in order to get a rectangle completely on the screen (or, if taller than the screen, at least the first screen size chunk of it).

Parameters
rect Rect!: The rect.
Return
Int The scroll delta.

getLeftFadingEdgeStrength

Added in API level 3
protected open fun getLeftFadingEdgeStrength(): Float

Returns the strength, or intensity, of the left faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.

Return
Float the intensity of the left fade as a float between 0.0f and 1.0f

getRightFadingEdgeStrength

Added in API level 3
protected open fun getRightFadingEdgeStrength(): Float

Returns the strength, or intensity, of the right faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.

Return
Float the intensity of the right fade as a float between 0.0f and 1.0f

measureChild

Added in API level 3
protected open fun measureChild(
    child: View!,
    parentWidthMeasureSpec: Int,
    parentHeightMeasureSpec: Int
): Unit

Ask one of the children of this view to measure itself, taking into account both the MeasureSpec requirements for this view and its padding. The heavy lifting is done in getChildMeasureSpec.

Parameters
child View!: The child to measure
parentWidthMeasureSpec Int: The width requirements for this view
parentHeightMeasureSpec Int: The height requirements for this view

measureChildWithMargins

Added in API level 3
protected open fun measureChildWithMargins(
    child: View!,
    parentWidthMeasureSpec: Int,
    widthUsed: Int,
    parentHeightMeasureSpec: Int,
    heightUsed: Int
): Unit

Ask one of the children of this view to measure itself, taking into account both the MeasureSpec requirements for this view and its padding and margins. The child must have MarginLayoutParams The heavy lifting is done in getChildMeasureSpec.

Parameters
child View!: The child to measure
parentWidthMeasureSpec Int: The width requirements for this view
widthUsed Int: Extra space that has been used up by the parent horizontally (possibly by other children of the parent)
parentHeightMeasureSpec Int: The height requirements for this view
heightUsed Int: Extra space that has been used up by the parent vertically (possibly by other children of the parent)

onLayout

Added in API level 3
protected open fun onLayout(
    changed: Boolean,
    l: Int,
    t: Int,
    r: Int,
    b: Int
): Unit

Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.

Parameters
changed Boolean: This is a new size or position for this view
left Left position, relative to parent
top Top position, relative to parent
right Right position, relative to parent
bottom Bottom position, relative to parent

onMeasure

Added in API level 3
protected open fun onMeasure(
    widthMeasureSpec: Int,
    heightMeasureSpec: Int
): Unit

Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int,int) and should be overridden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call setMeasuredDimension(int,int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int,int). Calling the superclass' onMeasure(int,int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int,int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

Parameters
widthMeasureSpec Int: horizontal space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.
heightMeasureSpec Int: vertical space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.

onOverScrolled

Added in API level 9
protected open fun onOverScrolled(
    scrollX: Int,
    scrollY: Int,
    clampedX: Boolean,
    clampedY: Boolean
): Unit

Called by overScrollBy(int,int,int,int,int,int,int,int,boolean) to respond to the results of an over-scroll operation.

Parameters
scrollX Int: New X scroll value in pixels
scrollY Int: New Y scroll value in pixels
clampedX Boolean: True if scrollX was clamped to an over-scroll boundary
clampedY Boolean: True if scrollY was clamped to an over-scroll boundary

onRequestFocusInDescendants

Added in API level 3
protected open fun onRequestFocusInDescendants(
    direction: Int,
    previouslyFocusedRect: Rect!
): Boolean

When looking for focus in children of a scroll view, need to be a little more careful not to give focus to something that is scrolled off screen. This is more expensive than the default android.view.ViewGroup implementation, otherwise this behavior might have been made the default.

Parameters
direction Int: One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT
previouslyFocusedRect Rect!: The rectangle (in this View's coordinate system) to give a finer grained hint about where focus is coming from. May be null if there is no hint.
Return
Boolean Whether focus was taken.

onRestoreInstanceState

Added in API level 3
protected open fun onRestoreInstanceState(state: Parcelable!): Unit

Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState. This function will never be called with a null state.
If you override this method you must call through to the superclass implementation.

Parameters
state Parcelable!: The frozen state that had previously been returned by onSaveInstanceState.

onSaveInstanceState

Added in API level 3
protected open fun onSaveInstanceState(): Parcelable?

Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state. This state should only contain information that is not persistent or can not be reconstructed later. For example, you will never store your current position on screen because that will be computed again when a new instance of the view is placed in its view hierarchy.

Some examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.
If you override this method you must call through to the superclass implementation.

Return
Parcelable? Returns a Parcelable object containing the view's current dynamic state, or null if there is nothing interesting to save.

onSizeChanged

Added in API level 3
protected open fun onSizeChanged(
    w: Int,
    h: Int,
    oldw: Int,
    oldh: Int
): Unit

This is called during layout when the size of this view has changed. If you were just added to the view hierarchy, you're called with the old values of 0.

Parameters
w Int: Current width of this view.
h Int: Current height of this view.
oldw Int: Old width of this view.
oldh Int: Old height of this view.