ScrollView in Android Last Updated : 15 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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.Some Important XML attributes of ScrollViewAttributeDescriptionandroid:fillViewportDefines whether the ScrollView should stretch its content to fill the viewport.android:measureAllChildrenDetermines whether to measure all children or just those in the VISIBLE or INVISIBLE state when measuring. Defaults to false.android:alphaalpha property of the view, as a value between 0 (completely transparent) and 1 (completely opaque).android:backgroundA drawable to use as the background. android:isScrollContainerSet 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:minHeightDefines the minimum height of the view.android:minWidthDefines the minimum width of the view.android:scrollbarsDefines which scrollbars should be displayed on scrolling or not.Steps to Implement ScrollView in AndroidThis example demonstrates the steps involved to create a ScrollView in Android using Kotlin.Step 1: Create a new projectClick on File, then New => New Project.Choose “Empty Activity” for the project template.Select language as Kotlin/Java.Select the minimum SDK (According to the need).Step 2: Modify activity_main.xml Add the ScrollView and inside the ScrollView add a TextView to display a very long string to trigger the scroll.activity_main.xml: activity_main.xml <?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:id="@+id/main" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" 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" android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="24sp" android:text="@string/sample_text" android:textColor="@color/green"/> </ScrollView> </androidx.constraintlayout.widget.ConstraintLayout> As already mentioned above, Scrollview can only contain one direct child. In this case, the child is TextView. On noticing this TextView you will realize that the text added inside TextView is mentioned as @string/sample_text which refers to a string resource inside the strings.xml file.Step 3: MainActivity file in the Android ApplicationThe MainActivity will be left untouched since it serves no purpose. MainActivity.java import android.os.Bundle; import androidx.activity.EdgeToEdge; import androidx.appcompat.app.AppCompatActivity; import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } MainActivity.kt package com.example.gfgapp_scrollview import androidx.appcompat.app.AppCompatActivity import android.os.Bundle class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) } } Output: Comment More infoAdvertise with us J jnikita356 Follow Improve Article Tags : Android Kotlin Android Android-View Java-Android Explore Android Tutorial 15+ min read BasicsIntroduction to Android Development 5 min read History of Android 15+ min read Best Way to Become Android Developer â A Complete Roadmap 7 min read Android Development Prerequisites [2025] - Things to Learn Before Android Development 8 min read Android App Development Fundamentals for Beginners 6 min read Android Architecture 5 min read Android System Architecture 3 min read Android Boot Process 4 min read Difference between Java and Kotlin in Android with Examples 3 min read Interesting Facts About Android 3 min read Software Setup and ConfigurationDownload and Instal JDK on Windows, Mac and Linux 7 min read Guide to Install and Setup IntelliJ IDEA for Android App Development 5 min read Guide to Install and Setup Visual Studio for Android App Development 4 min read How to Run the Android App on a Real Device? 2 min read Resolving frequently occurring errors in Android Development 3 min read Android Studio Tutorial 9 min read File Structure & ComponentsComponents of an Android Application 3 min read Introduction to Activities in Android 6 min read Services in Android with Example 10 min read Core TopicsHow Does Android App Work? 7 min read Activity Lifecycle in Android with Demo App 9 min read Introduction to Gradle 4 min read What is Context in Android? 9 min read Bundle in Android with Example 6 min read Activity State Changes In Android with Example 6 min read Processes and Application Lifecycle in Android 7 min read Desugaring in Android 4 min read Difference Between AndroidX and Android Support Libraries 3 min read Memory Leaks in Android 7 min read Layout & ViewLayouts in Android UI Design 3 min read Android UI Layouts 5 min read LinearLayout and its Important Attributes with Examples in Android 3 min read Android LinearLayout in Kotlin 2 min read Android RelativeLayout in Kotlin 4 min read ConstraintLayout in Android 6 min read TextView widget in Android with Examples 5 min read TextView in Kotlin 3 min read Working With the TextView in Android 7 min read Autosizing TextView in Android 6 min read ButtonButton in Android 3 min read How to Add Radio Buttons in an Android Application? 5 min read RadioButton in Kotlin 4 min read How to add Toggle Button in an Android Application 3 min read ToggleButton in Kotlin 2 min read RadioGroup in Kotlin 3 min read Intent and Intent FiltersWhat is Intent in Android? 4 min read Implicit and Explicit Intents in Android with Examples 6 min read How to Send Data From One Activity to Second Activity in Android? 7 min read How to open dialer in Android through Intent? 3 min read Creating Multiple Screen Applications in Android 6 min read How to Open Camera Through Intent and Display Captured Image in Android? 6 min read Toast & RecyclerViewToasts for Android Studio 2 min read What is Toast and How to Use it in Android with Examples? 6 min read Android Toast in Kotlin 3 min read How to Change Toast font in Android? 3 min read How to add a custom styled Toast in Android 4 min read RecyclerView in Android with Example 7 min read Android | Horizontal RecyclerView with Examples 4 min read How to create a nested RecyclerView in Android 5 min read How to Create RecyclerView with Multiple ViewType in Android? 6 min read RecyclerView using ListView in Android With Example 5 min read Like