Android ScrollView not scrolling

18,576

Solution 1

I removed this line from the AndroidManifest.xml file

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

and added this line

android:theme="@android:style/Theme.NoTitleBar"

it has both fixed my scrolling app and made my app look more visually appealing. However, I am not sure if this is the correct fix.

Solution 2

For me, remove android:windowSoftInputMode="adjustPan" of the <activity> tag in AndroidManifest.xml file solved the problem.

Share:
18,576
papezjustin
Author by

papezjustin

Updated on June 04, 2022

Comments

  • papezjustin
    papezjustin almost 2 years

    I have solved my question. I chose to instead have a header and a footer that are always located at the bottom and top of the screen respectively. Then I created a "center content" which I enclosed within a ScrollView layout. I have updated the code below if people are interested in seeing what it now looks like.

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:background="#FFFFFF">
    
        <LinearLayout android:id="@+id/header"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@layout/header"
            android:layout_alignParentTop="true">
            <ImageView android:src="@drawable/logo"
                android:contentDescription="@string/logo_description"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dip"/>
        </LinearLayout>
    
        <ScrollView android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="350dip"
            android:layout_below="@id/header">
            <LinearLayout android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="20dip" >
                <!--  Email Label -->
                <TextView android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:textColor="#372C24"
                    android:text="@string/email"/>
                <EditText android:id="@+id/email_field"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dip"
                    android:singleLine="true"
                    android:inputType="textEmailAddress"/>
                <!--  Password Label -->
                <TextView android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dip"
                    android:textColor="#372C24"
                    android:text="@string/password"/>
                <EditText android:id="@+id/password_field"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:inputType="textPassword"/>
                <!-- Login button -->
                <Button android:id="@+id/login_button"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="25dip"
                    android:text="@string/login"/>
                <!-- Register button -->
                <Button android:id="@+id/register_button"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="25dip"
                    android:text="@string/register_button"/>
            </LinearLayout>
        </ScrollView>
    
        <LinearLayout android:id="@+id/footer"
            android:layout_width="fill_parent"
            android:layout_height="90dip"
            android:background="@layout/footer"
            android:layout_alignParentBottom="true">
        </LinearLayout>
    
    </RelativeLayout>
    
  • wtsang02
    wtsang02 over 11 years
    Its not true. you can have any, but only one child in scrollview
  • papezjustin
    papezjustin over 11 years
    Scroll views ARE NOT required to have a LinearLayout as their immediate child. developer.android.com/reference/android/widget/ScrollView.ht‌​ml
  • Quentin S.
    Quentin S. about 9 years
    According to Android guidelines, android:layout_height attribute of the first (and only) ScrollView children should always be "wrap_content". You will get a Lint warning if you use match_parent.
  • Skynet
    Skynet over 8 years
    I wonder what is the alternative if I want to use the above attribute!