ScrollView

ScrollView

⇒ In Android, a ScrollView is a view group that is used to make vertically scrollable views.
  • A scroll view contains a single direct child only.
  • In order to place multiple views in the scroll view, one needs to make a view group(like LinearLayout) as a direct child and then we can define many views inside it.
  • A ScrollView supports Vertical scrolling only, so in order to create a horizontally scrollable view, HorizontalScrollView is used.
Attributes
Description
android:alpha
alpha property of the view, as a value between 0 (completely transparent) and 1 (completely opaque).
android:background
A drawable to use as the background.
android:clickable
Defines whether this view reacts to click events.
android:contentDescription
Defines text that briefly describes content of the view.
android:id
Supply an identifier name for this view, to later retrieve it with View.findViewById() or Activity.findViewById().
android:isScrollContainer
Set this if the view will serve as a scrolling container, meaning that it can be resized to shrink its overall window so that there will be space for an input method.
android:minHeight
Defines the minimum height of the view.
android:minWidth
Defines the minimum width of the view.
android:onClick
Name of the method in this View’s context to invoke when the view is clicked.
android:padding
Sets the padding, in pixels, of all four edges.
android:scrollbars
Defines which scrollbars should be displayed on scrolling or not.
Attributes
Description
android:addStatesFromChildren
Sets whether this ViewGroup’s drawable states also include its children’s drawable states.
android:animateLayoutChanges
Defines whether changes in layout should cause a LayoutTransition to run.
android:clipChildren
Defines whether a child is limited to draw inside of its bounds or not.
android:clipToPadding
Defines whether the ViewGroup will clip its children and resize any EdgeEffect to its padding, if padding is not zero.
android:layoutAnimation
Defines the layout animation to use the first time the ViewGroup is laid out.
android:layoutMode
Defines the layout mode of this ViewGroup.
android:splitMotionEvents
Sets whether this ViewGroup should split MotionEvents to separate child views during touch event dispatch.
<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" tools:layout_editor_absoluteX="0dp" tools:layout_editor_absoluteY="-127dp"> <TextView android:id="@+id/scrolltext" style="@style/AppTheme" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/scrolltext" android:textColor="@color/green"/> </ScrollView> </androidx.constraintlayout.widget.ConstraintLayout>