0

Hi i have a profile activity in which the user is brought to upon logging in then this has fragments to different pages. I want these fragments to have a scroll feature but upon using the scroll view this does nothing. What are my options in order to get the fragment to scroll.

I have tried putting the scroll view into the profile activity and into the fragments themselves.

<?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    tools:context=".ProfileActivity">

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.39"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.436">

        <Button
            android:id="@+id/buttonLogout"
            android:layout_width="60dp"
            android:layout_height="25dp"
            android:layout_marginStart="347dp"
            android:layout_marginLeft="0dp"
            android:layout_marginTop="0dp"
            android:layout_marginEnd="0dp"
            android:layout_marginRight="0dp"
            android:layout_marginBottom="0dp"
            android:background="@color/design_default_color_primary"
            android:textColor="@android:color/background_light"
            android:text="@string/logout" />

        <android.support.design.widget.BottomNavigationView
            android:id="@+id/main_nav"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:layout_alignParentStart="true"
            android:layout_alignParentBottom="true"
            app:menu="@menu/navigation">

        </android.support.design.widget.BottomNavigationView>

        <ImageView
            android:id="@+id/uobLogo"
            android:layout_width="70dp"
            android:layout_height="60dp"
            android:layout_marginStart="0dp"
            android:layout_marginLeft="0dp"
            android:layout_marginTop="0dp"
            android:layout_marginEnd="0dp"
            android:layout_marginRight="0dp"
            android:layout_marginBottom="0dp"
            android:src="@drawable/uoblogo" />

        <FrameLayout
            android:id="@+id/main_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@id/main_nav"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true">
        </FrameLayout>

    </RelativeLayout>
</android.support.constraint.ConstraintLayout>

//above code is from the profile activity xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
    tools:context=".SymptomsFragment">

    <TextView
        android:id="@+id/TitleSymptoms"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center_horizontal"
        android:textSize="40sp"
        android:textStyle="bold"
        android:textColor="@color/design_default_color_primary"
        android:text="@string/TitleSymptoms"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/paragraph2"
        android:layout_width="match_parent"
        android:layout_height="435dp"
        android:layout_gravity="center_vertical"
        android:textSize="14sp"
        android:textStyle="italic"
        android:textColor="@color/colorAccent"
        android:text="@string/paragraph2" />

</FrameLayout>

//above code is from the symptoms fragment

Zoe
  • 27,060
  • 21
  • 118
  • 148

1 Answers1

0

Try to do something like this:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ProfileActivity">

<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!--Here you put your views-->


</android.support.constraint.ConstraintLayout>

</ScrollView>

So the idea is that your parent layout, in this case is ScrollView, contains all the views you need to scroll, in this case your RelativeLayout with all the views it contains

Victor Ortiz
  • 791
  • 1
  • 12
  • 23