How to work with scroller view in android?

How to work with scroller view in android?
December 7, 2018 No Comments Android Development Pushpendra Kumar



ScrollerView

If you want to become a good developer then you must understand the hierarchy of the views. Here we have one most important topic to discuss with you and which is based on the scroller view. So let’s learn the scroller view hierarchy.

The android.widget.ScrollView class provides the functionality of scroll view. ScrollView is used to scroll the child elements of palette inside ScrollView. Android supports vertical scroll view as default scroll view. Vertical ScrollView scrolls elements vertically. And Android uses HorizontalScrollView for horizontal ScrollView.

Basically, for any scrolling area, we have the parent as scroller view. Here I am going to tell the hierarchy of scroller view.

<?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fillViewport="true">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <!--Any others layout will come inside that-->

            </LinearLayout>

        </ScrollView>

    </android.support.constraint.ConstraintLayout>




Why it's happened, As per my study and my experience we cannot take multiple child views for a single scroller view. Why? Because if you will take multiple child views into the scroller view then the compiler will get confused and unable to generate the output. Because if scroller view has the single child then it’s clear for the compiler that scroller will scroll that single view. And this methodology is applicable to both scroller view. Both, I mean to say HorizontalScrollerview and ScrollerView.


Tags
About The Author
Pushpendra Kumar I am passionate about mobile application development and professional developer at Colour Moon Technologies Pvt Ltd (www.thecolourmoon.com). This website I have made so that I can meet with new challenges and can share here.

Leave a reply

Your email address will not be published. Required fields are marked *