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