public class

ScrollView

extends View
java.lang.Object
   ↳ com.neomades.ui.View
     ↳ com.neomades.ui.ScrollView

Class Overview

A ScrollView represents a view with scrollbars (vertical and/or horizontal).

Default properties

By default, ScrollView is a VerticalLayout vertically scrollable. Horizontal scroll can be added calling setHorizontalScroll(boolean). You change the type of Layout, by calling the setContent(Layout) method.

Cross Platform Considerations

  • Avoid setting MATCH_CONTENT for ListViews or ScrollViews at all times.
  • Avoid setting MATCH_PARENT for height of the ScrollView's content at all times.
The hierarchy of ScrollView is also concerned by this note. MATCH_CONTENT in the hierarchy could break down the ScrollView display.

Summary

XML Attributes
Attribute Name Related Method Description
horizontalScroll setHorizontalScroll(boolean) If the scrollview could scroll horizontally  
verticalScroll setVerticalScroll(boolean) If the scrollview could scroll vertically  
[Expand]
Inherited XML Attributes
From class com.neomades.ui.View
[Expand]
Inherited Constants
From interface com.neomades.ui.Alignment
From interface com.neomades.ui.StretchMode
Public Constructors
ScrollView()
Creates a new ScrollView.
Public Methods
void scrollTo(int x, int y)
Set the scrolled position of the content view.
void setContent(Layout layout)
Set content of the ScrollView.
void setHorizontalScroll(boolean scroll)
Enables or disables the horizontal scroll
void setScrollbarAlwaysVisible(boolean alwaysVisible)
Enables scroll bars of this ScrollView to be always visible (even if the ScrollView is not scrolling).
void setVerticalScroll(boolean scroll)
Enables or disables the vertical scroll
[Expand]
Inherited Methods
From class com.neomades.ui.View
From class java.lang.Object

XML Attributes

horizontalScroll

If the scrollview could scroll horizontally

verticalScroll

If the scrollview could scroll vertically

Related Methods

Public Constructors

public ScrollView ()

Creates a new ScrollView.

Public Methods

public void scrollTo (int x, int y)

Set the scrolled position of the content view.

Parameters
x the x position (in DP units) to scroll to
y the y position (in DP units) to scroll to

public void setContent (Layout layout)

Set content of the ScrollView.

Note that if the layout is a VerticalLayout, vertical scroll will be enabled by default. If the layout is a HorizontalLayout, horizontal scroll will be enabled by default. The scroll direction can be changed calling setHorizontalScroll(boolean) or setVerticalScroll(boolean).

Parameters
layout ScrollView content
Throws
CrossThreadException if the method is called from outside the UI-Thread
IllegalStateException if the layout has already a parent

public void setHorizontalScroll (boolean scroll)

Enables or disables the horizontal scroll

Related XML Attributes
Parameters
scroll true if the scrollbar could appear
Throws
CrossThreadException if the method is called from outside the UI-Thread

public void setScrollbarAlwaysVisible (boolean alwaysVisible)

Enables scroll bars of this ScrollView to be always visible (even if the ScrollView is not scrolling).

Parameters
alwaysVisible true to be always visible, false if visible when the view is scrolling

public void setVerticalScroll (boolean scroll)

Enables or disables the vertical scroll

Related XML Attributes
Parameters
scroll true if the scrollbar could appear
Throws
CrossThreadException if the method is called from outside the UI-Thread