Search code examples
androidandroid-scrollview

ScrollView between two static views?


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

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:background="#e5e5e5"
    android:fillViewport="true" >

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

        <TextView
            android:id="@+id/textView1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#fff"
            android:paddingBottom="10dp"
            android:paddingLeft="15dp"
            android:paddingRight="15dp"
            android:paddingTop="10dp"
            android:text="Premium Subscriptiondd"
            android:textAppearance="?android:attr/textAppearanceMedium" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:paddingTop="10dp" >

                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="200dp"
                    android:layout_height="wrap_content"
                    android:paddingLeft="5dp"
                    android:paddingRight="5dp"
                    android:text="Register with LBC Podcasts"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:textColor="@color/tv_grey_dark" />

                <TextView
                    android:id="@+id/TextView03"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingBottom="5dp"
                    android:paddingLeft="5dp"
                    android:paddingRight="5dp"
                    android:text="Allows downloads from LBC Podcasts website as well"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:textColor="@color/tv_grey_dark"
                    android:textSize="12sp" />

                <com.lbc.podcasts.AccountFragments.FloatLabeledEditText
                    android:id="@+id/firstname_et"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    float:fletFloatingHint="First name" >
                </com.lbc.podcasts.AccountFragments.FloatLabeledEditText>

                <com.lbc.podcasts.AccountFragments.FloatLabeledEditText
                    android:id="@+id/lastname_et"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    float:fletFloatingHint="Last name" >
                </com.lbc.podcasts.AccountFragments.FloatLabeledEditText>

                <com.lbc.podcasts.AccountFragments.FloatLabeledEditText
                    android:id="@+id/email_et"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    float:fletFloatingHint="Email" >
                </com.lbc.podcasts.AccountFragments.FloatLabeledEditText>

                <com.lbc.podcasts.AccountFragments.FloatLabeledEditText
                    android:id="@+id/password_et"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    float:fletFloatingHint="Password"
                    float:fletInputType="textPassword" >
                </com.lbc.podcasts.AccountFragments.FloatLabeledEditText>

                <com.lbc.podcasts.AccountFragments.FloatLabeledEditText
                    android:id="@+id/confirm_password_et"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    float:fletFloatingHint="Confirm password"
                    float:fletInputType="textPassword" >
                </com.lbc.podcasts.AccountFragments.FloatLabeledEditText>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="horizontal" >

                    <Button
                        android:id="@+id/skip_btn"
                        android:layout_width="fill_parent"
                        android:layout_height="40dp"
                        android:layout_marginRight="5dp"
                        android:layout_weight="1"
                        android:background="@color/tv_blue"
                        android:padding="5dp"
                        android:text="Skip"
                        android:textColor="#fff"
                        android:textStyle="bold" />

                    <Button
                        android:id="@+id/sign_up_btn"
                        android:layout_width="fill_parent"
                        android:layout_height="40dp"
                        android:layout_marginLeft="5dp"
                        android:layout_weight="1"
                        android:background="@color/tv_blue"
                        android:padding="5dp"
                        android:text="Register"
                        android:textColor="#fff"
                        android:textStyle="bold" />
                </LinearLayout>
            </LinearLayout>

    </LinearLayout>

      </ScrollView>



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

        <View
            android:id="@+id/View02"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#BBBBBB" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#fff"
            android:paddingLeft="5dp" >

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:padding="5dp"
                android:text="Already a subscriber?"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="@color/tv_grey_dark" />

            <Button
                android:id="@+id/go_to_sign_in_btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="?android:attr/selectableItemBackground"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:text="Sign In"
                android:textColor="@color/tv_blue" />
        </LinearLayout>

        <View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#BBBBBB" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#fff" >

            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="?android:attr/selectableItemBackground"
                android:text="Help"
                android:textColor="@color/tv_blue" />

            <View
                android:id="@+id/View01"
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#BBBBBB" />

            <Button
                android:id="@+id/why_sub_btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="?android:attr/selectableItemBackground"
                android:text="Why Subscribe?"
                android:textColor="@color/tv_blue" />
        </LinearLayout>
    </LinearLayout>

</RelativeLayout>

which creates:

enter image description here

As you can see, the scrollview for the middle content (EditTexts etc) goes below the bottom nav and CANNOT be scrolled?

I've tried EVERY layout configuration i can think of, all combinations of layout sizes.

The ONLY method that seems to work is setting a fixed dp height on the scrollview. Not ideal and non responsive for devices.

Any help is GREATLY appreciated at this point.


Solution

  • It cannot be scrolled because scroll view is below the bottom navigation bar. So navigation bar obstructs last few items in ScrollView. Make sure that the ScrollView is above bottom navigation bar. Try this

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:float="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:background="#e5e5e5"
        android:layout_above="@+id/nav_bar"
        android:fillViewport="true" >
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >
    
            <TextView
                android:id="@+id/textView1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#fff"
                android:paddingBottom="10dp"
                android:paddingLeft="15dp"
                android:paddingRight="15dp"
                android:paddingTop="10dp"
                android:text="Premium Subscriptiondd"
                android:textAppearance="?android:attr/textAppearanceMedium" />
    
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="fill_parent"
                    android:orientation="vertical"
                    android:paddingBottom="10dp"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:paddingTop="10dp" >
    
                    <TextView
                        android:id="@+id/textView2"
                        android:layout_width="200dp"
                        android:layout_height="wrap_content"
                        android:paddingLeft="5dp"
                        android:paddingRight="5dp"
                        android:text="Register with LBC Podcasts"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="@color/tv_grey_dark" />
    
                    <TextView
                        android:id="@+id/TextView03"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingBottom="5dp"
                        android:paddingLeft="5dp"
                        android:paddingRight="5dp"
                        android:text="Allows downloads from LBC Podcasts website as well"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="@color/tv_grey_dark"
                        android:textSize="12sp" />
    
                    <com.lbc.podcasts.AccountFragments.FloatLabeledEditText
                        android:id="@+id/firstname_et"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        float:fletFloatingHint="First name" >
                    </com.lbc.podcasts.AccountFragments.FloatLabeledEditText>
    
                    <com.lbc.podcasts.AccountFragments.FloatLabeledEditText
                        android:id="@+id/lastname_et"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        float:fletFloatingHint="Last name" >
                    </com.lbc.podcasts.AccountFragments.FloatLabeledEditText>
    
                    <com.lbc.podcasts.AccountFragments.FloatLabeledEditText
                        android:id="@+id/email_et"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        float:fletFloatingHint="Email" >
                    </com.lbc.podcasts.AccountFragments.FloatLabeledEditText>
    
                    <com.lbc.podcasts.AccountFragments.FloatLabeledEditText
                        android:id="@+id/password_et"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        float:fletFloatingHint="Password"
                        float:fletInputType="textPassword" >
                    </com.lbc.podcasts.AccountFragments.FloatLabeledEditText>
    
                    <com.lbc.podcasts.AccountFragments.FloatLabeledEditText
                        android:id="@+id/confirm_password_et"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        float:fletFloatingHint="Confirm password"
                        float:fletInputType="textPassword" >
                    </com.lbc.podcasts.AccountFragments.FloatLabeledEditText>
    
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        android:orientation="horizontal" >
    
                        <Button
                            android:id="@+id/skip_btn"
                            android:layout_width="fill_parent"
                            android:layout_height="40dp"
                            android:layout_marginRight="5dp"
                            android:layout_weight="1"
                            android:background="@color/tv_blue"
                            android:padding="5dp"
                            android:text="Skip"
                            android:textColor="#fff"
                            android:textStyle="bold" />
    
                        <Button
                            android:id="@+id/sign_up_btn"
                            android:layout_width="fill_parent"
                            android:layout_height="40dp"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:background="@color/tv_blue"
                            android:padding="5dp"
                            android:text="Register"
                            android:textColor="#fff"
                            android:textStyle="bold" />
                    </LinearLayout>
                </LinearLayout>
    
        </LinearLayout>
    
          </ScrollView>
    
    
    
        <LinearLayout
            android:id="@id/nav_bar"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:orientation="vertical" >
    
            <View
                android:id="@+id/View02"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="#BBBBBB" />
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#fff"
                android:paddingLeft="5dp" >
    
                <TextView
                    android:id="@+id/textView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:padding="5dp"
                    android:text="Already a subscriber?"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:textColor="@color/tv_grey_dark" />
    
                <Button
                    android:id="@+id/go_to_sign_in_btn"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="?android:attr/selectableItemBackground"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:text="Sign In"
                    android:textColor="@color/tv_blue" />
            </LinearLayout>
    
            <View
                android:id="@+id/view1"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="#BBBBBB" />
    
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#fff" >
    
                <Button
                    android:id="@+id/button1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:background="?android:attr/selectableItemBackground"
                    android:text="Help"
                    android:textColor="@color/tv_blue" />
    
                <View
                    android:id="@+id/View01"
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#BBBBBB" />
    
                <Button
                    android:id="@+id/why_sub_btn"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:background="?android:attr/selectableItemBackground"
                    android:text="Why Subscribe?"
                    android:textColor="@color/tv_blue" />
            </LinearLayout>
        </LinearLayout>
    
    </RelativeLayout>
    

    ..

    These are the two extra lines I added

    android:layout_above="@+id/nav_bar"
    

    ..

    android:id="@id/nav_bar"