3

Below is my XML code, I want the whole view to scroll, but it's just not working, please help, with what's wrong;

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

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/app_icon"
    android:layout_marginTop="20dp"
    android:layout_gravity="center_horizontal"/>

<TextView
    android:id="@+id/textView_app_version"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"
    android:layout_gravity="center"/>

<TextView
    android:id="@+id/textView_content"
    android:layout_width="match_parent"
    android:layout_marginTop="15dp"
    android:layout_height="386dp"
    android:gravity="center"></TextView>

</LinearLayout>
</ScrollView>

I've tried using, android:fillViewport="true"

but of no help.

pratiti-systematix
  • 792
  • 11
  • 28

4 Answers4

2

A ScrollView 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.

So here you have to take LinearLayout or RelativeLayout and then you have to put different hierarchy of component.

Android : buttons not visible in scrollview

here i have given answer of Some problem so you can follow this for solve your problem with clearing your concept.

Community
  • 1
  • 1
Pranav P
  • 1,755
  • 19
  • 39
1

Try like this ,Scrolling will work till End

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

     <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >


            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/app_icon"
                android:layout_marginTop="20dp"
                android:layout_gravity="center_horizontal"/>

            <TextView
                android:id="@+id/textView_app_version"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:layout_gravity="center"/>

            <TextView
                android:id="@+id/textView_content"
                android:layout_width="match_parent"
                android:layout_marginTop="15dp"
                android:layout_height="386dp"
                android:gravity="center"/>

        </LinearLayout>
    </ScrollView>
</Relativelayout>
Android Dev
  • 421
  • 8
  • 26
1

If ScrollView fits to your device screen it would not be scrollable, so make sure content inside ScrollView takes space larger than your screen size.

0

systematix Try this,here you getting scroll.

<?xml version="1.0" encoding="utf-8"?>

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

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="20dp"
        android:src="@mipmap/ic_launcher" />

    <TextView
        android:id="@+id/textView_app_version1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:text="hello" />

    <TextView
        android:id="@+id/textView_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:gravity="center"
        android:text="fahfhahffshfs fsfhshf fshfs sflshf sflsh fhsfhslfh fshflshf hslfh slfhslfhslfhs fhslhf"></TextView>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="20dp"
        android:src="@mipmap/ic_launcher" />

    <TextView
        android:id="@+id/textView_app_version"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:text="hello" />

    <TextView
        android:id="@+id/textView_content1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:gravity="center"
        android:text="fahfhahffshfs fsfhshf fshfs sflshf sflsh fhsfhslfh fshflshf hslfh slfhslfhslfhs fhslhf"></TextView>


    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="20dp"
        android:src="@mipmap/ic_launcher" />

    <TextView
        android:id="@+id/textView_app_version2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:text="hello" />

    <TextView
        android:id="@+id/textView_content3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:gravity="center"
        android:text="fahfhahffshfs fsfhshf fshfs sflshf sflsh fhsfhslfh fshflshf hslfh slfhslfhslfhs fhslhf"></TextView>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="20dp"
        android:src="@mipmap/ic_launcher" />

    <TextView
        android:id="@+id/textView_app_version4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:text="hello" />

    <TextView
        android:id="@+id/textView_content4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:gravity="center"
        android:text="fahfhahffshfs fsfhshf fshfs sflshf sflsh fhsfhslfh fshflshf hslfh slfhslfhslfhs fhslhf"></TextView>


</LinearLayout>

Sachin Suthar
  • 692
  • 10
  • 28