Added in API level 1

ScrollView


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

A view group that allows the view hierarchy placed within it to be scrolled. Scroll view may have only one direct child placed within it. To add multiple views within the scroll view, make the direct child you add a view group, for example LinearLayout, and place additional views within that LinearLayout.

Scroll view supports vertical scrolling only. For horizontal scrolling, use HorizontalScrollView instead.

Never add a androidx.recyclerview.widget.RecyclerView or ListView to a scroll view. Doing so results in poor user interface performance and a poor user experience.

For vertical scrolling, consider androidx.core.widget.NestedScrollView instead of scroll view which offers greater user interface flexibility and support for the material design scrolling patterns.

Material Design offers guidelines on how the appearance of several UI components, including app bars and banners, should respond to gestures.

Summary

XML attributes
android:fillViewport Defines whether the scrollview should stretch its content to fill the viewport.
Inherited XML attributes
Inherited constants
Public constructors
ScrollView(context: Context!)

ScrollView(context: Context!, attrs: AttributeSet!)

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

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

Public methods
open Unit
addView(child: View!)

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

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

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

open Boolean
arrowScroll(direction: Int)

Handle scrolling in response to an up or down arrow click.

open Unit

open Boolean

open Unit
draw(canvas: 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(velocityY: Int)

Fling the scroll view

open Boolean
fullScroll(direction: Int)

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

open CharSequence!

open Int

Returns the bottom edge effect color.

open Int

open Int

Returns the top edge effect color.

open Boolean

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

open Boolean

open Boolean

open Boolean

open Boolean
onNestedFling(target: View, velocityX: Float, velocityY: Float, consumed: Boolean)

open Unit
onNestedScroll(target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int)

open Unit
onNestedScrollAccepted(child: View, target: View, axes: Int)

open Boolean
onStartNestedScroll(child: View, target: View, nestedScrollAxes: Int)

open Unit

open Boolean

open Boolean
pageScroll(direction: Int)

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

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

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

open Unit

open Unit

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

Set the scrolled position of your view.

open Unit

Scrolls the view to the given child.

open Unit

Sets the bottom edge effect color.

open Unit

Sets the edge effect color for both top and bottom edge effects.

open Unit
setFillViewport(fillViewport: Boolean)

Indicates this ScrollView whether it should stretch its content height to fill the viewport or not.

open Unit
setSmoothScrollingEnabled(smoothScrollingEnabled: Boolean)

Set whether arrow scrolling will animate its transition.

open Unit

Sets the top edge effect color.

open Boolean

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 amount to scroll in the Y 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 Int

open Int

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

open Float

open Float

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

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

open Unit

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

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

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

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

open Parcelable?

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

Inherited functions