0

I have a ScrollView, and I've made sure that it only has one child, and that it's set to match_parent like in previous posts, but I still can't get it to scroll. Can anyone help me out?

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:fillViewport="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >


        <fragment
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight=".8"
            tools:context="com.thevisitapp.visitapp.PlacesActivity"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:id="@+id/map" />


        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            android:orientation="vertical">


            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/summaryLabel"
                android:paddingLeft="16dp"
                android:background="@color/gray"
                android:text="summary"/>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/summary"
                android:layout_below="@+id/summaryLabel"
                android:paddingLeft="16dp"
                android:paddingTop="16dp"
                android:paddingBottom="10dp"
                tools:text="actual summary"/>

            <LinearLayout
                android:id="@+id/contactsLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone"
                android:layout_below="@+id/summary"
                android:orientation="horizontal"
                >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/contactsLabel"
                    android:background="@color/gray"
                    android:paddingLeft="16dp"
                    android:text="contact"/>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/phoneLayout"
                    android:orientation="horizontal"
                    android:visibility="gone">

                    <ImageView
                        android:id="@+id/phoneImage"
                        android:src="@drawable/icon_phone"
                        android:layout_width="60dp"
                        android:layout_height="60dp"/>

                    <TextView
                        android:id="@+id/phoneNumber"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingTop="16dp"
                        tools:text="phoneNumber"/>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/emailLayout"
                    android:paddingLeft="16dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:visibility="gone">

                    <ImageView
                        android:id="@+id/emailImage"
                        android:src="@drawable/icon_email"
                        android:layout_width="60dp"
                        android:layout_height="60dp" />

                    <TextView
                        android:id="@+id/email"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        tools:text="email"/>
                </LinearLayout>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/mediaLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_below="@+id/contactsLayout"
                android:visibility="gone">

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

                    <TextView
                        android:id="@+id/media"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Media"
                        android:background="@color/gray"
                        android:paddingLeft="16dp"/>

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:paddingLeft="16dp"
                        android:paddingTop="10dp">

                        <ImageView
                            android:id="@+id/facebook"
                            android:layout_width="50dp"
                            android:layout_height="50dp"
                            android:src="@drawable/icon_facebook" />

                        <ImageView
                            android:id="@+id/twitter"
                            android:layout_width="50dp"
                            android:layout_height="50dp"
                            android:src="@drawable/icon_twitter"
                            android:layout_marginLeft="10dp"/>
                    </LinearLayout>
                </LinearLayout>

            </LinearLayout>
            <ProgressBar
                style="?android:attr/progressBarStyleSmall"
                android:indeterminate="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/progressBar"
                android:layout_above="@+id/contactsLayout"
                android:layout_centerHorizontal="true" />

        </RelativeLayout>
    </LinearLayout>
</ScrollView>
5
  • 2
    Change the outermost LinearLayout's layout_height to wrap_content. Commented Oct 12, 2015 at 6:06
  • The scrollview only scrolls if its height is bigger than the parent height. Is that the case in your layout? Commented Oct 12, 2015 at 6:07
  • @MikeM made the change, but still no luck. Commented Oct 12, 2015 at 6:14
  • and @oberflansch yes it is bigger than the parent height. Commented Oct 12, 2015 at 6:14
  • 1
    Oh, I bet it doesn't like your nested MapFragment. See if it'll scroll if you remove that temporarily. Commented Oct 12, 2015 at 6:15

2 Answers 2

1

1.Use wrap content in sub views.

2.Try to add a parent view (Linear or relative) and then add a child scroll view .This gives you more control over the entire view

Sign up to request clarification or add additional context in comments.

3 Comments

I made edited my code so that it is wrapped by a RelativeLayout and added nothing besides that. However, it still doesn't work. I also tried changing all the subviews to wrap_content
The fragment that u r using might be consuming the scroll gesture try commenting it and test.
That did it. So I'm guessing my temporary solution will be to just make the content underneath the fragment scrollable.
0

LinearLayout should be wrap_content instead of match_parent.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.