0

enter image description here

I am facing a weird problem where this screen is not scrollable.

Here is my layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:fresco="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_add_photo"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:animateLayoutChanges="true"
    android:background="#262626"
    tools:context="com.galleri5.android.activities.AddPhotoActivity">

    <RelativeLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="12dp"
        android:layout_marginStart="12dp"
        android:layout_marginTop="20dp"
        android:animateLayoutChanges="true">

        <TextView
            android:id="@+id/title"
            fontPath="fonts/OpenSans-Bold.ttf"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_centerVertical="true"
            android:layout_toLeftOf="@+id/crossButton"
            android:layout_toStartOf="@+id/crossButton"
            android:animateLayoutChanges="true"
            android:maxLines="1"
            android:text="Add Photo"
            android:textColor="#F0F0E9"
            android:textSize="20sp"
            tools:ignore="MissingPrefix" />

        <ImageView
            android:id="@+id/crossButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:animateLayoutChanges="true"
            android:paddingEnd="12dp"
            android:paddingLeft="12dp"
            android:paddingRight="12dp"
            android:paddingStart="12dp"
            android:src="@drawable/ic_cross_white_large" />

    </RelativeLayout>

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/header"
        android:layout_marginEnd="12dp"
        android:layout_marginLeft="12dp"
        android:layout_marginRight="12dp"
        android:layout_marginStart="12dp"
        android:animateLayoutChanges="true">

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

            <RelativeLayout
                android:id="@+id/imageContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:animateLayoutChanges="true">

                <com.facebook.drawee.view.SimpleDraweeView
                    android:id="@+id/image"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:animateLayoutChanges="true"
                    fresco:actualImageScaleType="centerCrop"
                    fresco:placeholderImage="@color/wait_color"
                    fresco:placeholderImageScaleType="centerCrop"
                    fresco:roundBottomLeft="false"
                    fresco:roundBottomRight="false"
                    fresco:roundTopLeft="true"
                    fresco:roundTopRight="true"
                    fresco:roundedCornerRadius="3dp" />

            </RelativeLayout>

            <LinearLayout
                android:id="@+id/metaContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="20dp"
                android:animateLayoutChanges="true"
                android:background="#424447"
                android:orientation="vertical">

                <RelativeLayout
                    android:id="@+id/locationContainer"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="12dp"
                    android:layout_marginLeft="12dp"
                    android:layout_marginRight="12dp"
                    android:layout_marginStart="12dp"
                    android:animateLayoutChanges="true">

                    <LinearLayout
                        android:id="@+id/blankLocationState"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:animateLayoutChanges="true"
                        android:orientation="horizontal"
                        android:paddingBottom="16dp"
                        android:paddingTop="16dp">

                        <ImageView
                            android:id="@+id/blankLocationIcon"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginEnd="4dp"
                            android:layout_marginRight="4dp"
                            android:animateLayoutChanges="true" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:animateLayoutChanges="true"
                            android:text="ADD LOCATION"
                            android:textColor="#F0F0E9"
                            android:textSize="10sp" />

                    </LinearLayout>

                    <RelativeLayout
                        android:id="@+id/activeLocationState"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="20dp"
                        android:layout_marginTop="20dp"
                        android:animateLayoutChanges="true"
                        android:background="@drawable/background_edittext"
                        android:visibility="gone">

                        <RelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="12dp"
                            android:layout_marginEnd="8dp"
                            android:layout_marginLeft="7dp"
                            android:layout_marginRight="8dp"
                            android:layout_marginStart="7dp"
                            android:layout_marginTop="12dp"
                            android:animateLayoutChanges="true">

                            <ImageView
                                android:id="@+id/activeLocationIcon"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginEnd="4dp"
                                android:layout_marginRight="4dp"
                                android:animateLayoutChanges="true" />

                            <AutoCompleteTextView
                                android:id="@+id/placeAutoComplete"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_toEndOf="@+id/activeLocationIcon"
                                android:layout_toLeftOf="@+id/deleteAutoComplete"
                                android:layout_toRightOf="@+id/activeLocationIcon"
                                android:layout_toStartOf="@+id/deleteAutoComplete"
                                android:animateLayoutChanges="true"
                                android:background="@null"
                                android:hint="e.g. Bangalore"
                                android:textColor="#424447"
                                android:textColorHint="#8A8A8A"
                                android:textSize="14sp" />

                            <ImageView
                                android:id="@+id/deleteAutoComplete"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_alignParentEnd="true"
                                android:layout_alignParentRight="true"
                                android:animateLayoutChanges="true"
                                android:paddingLeft="8dp"
                                android:paddingStart="8dp" />

                        </RelativeLayout>

                    </RelativeLayout>

                    <LinearLayout
                        android:id="@+id/afterLocationState"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:animateLayoutChanges="true"
                        android:orientation="vertical"
                        android:visibility="gone">

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="16dp"
                            android:animateLayoutChanges="true"
                            android:orientation="horizontal">

                            <ImageView
                                android:id="@+id/afterLocationIcon"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginEnd="4dp"
                                android:layout_marginRight="4dp"
                                android:animateLayoutChanges="true" />

                            <TextView
                                android:id="@+id/afterLocationText"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:animateLayoutChanges="true"
                                android:textColor="#8A8A8A"
                                android:textSize="10sp" />

                        </LinearLayout>

                        <TextView
                            android:id="@+id/afterLocationEdit"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="16dp"
                            android:layout_marginTop="12dp"
                            android:animateLayoutChanges="true"
                            android:text="EDIT"
                            android:textColor="#F0F0E9"
                            android:textSize="10sp" />

                    </LinearLayout>

                    <View
                        android:id="@+id/locationLine"
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_alignParentBottom="true"
                        android:animateLayoutChanges="true"
                        android:background="#262626" />

                </RelativeLayout>

                <RelativeLayout
                    android:id="@+id/captionContainer"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="12dp"
                    android:layout_marginLeft="12dp"
                    android:layout_marginRight="12dp"
                    android:layout_marginStart="12dp"
                    android:animateLayoutChanges="true">

                    <TextView
                        android:id="@+id/beforeAddCaption"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:animateLayoutChanges="true"
                        android:paddingBottom="16dp"
                        android:paddingTop="16dp"
                        android:text="ADD A CAPTION"
                        android:textColor="#F0F0E9"
                        android:textSize="10sp" />

                    <RelativeLayout
                        android:id="@+id/activeCaptionState"
                        android:layout_width="match_parent"
                        android:layout_height="120dp"
                        android:layout_marginBottom="20dp"
                        android:animateLayoutChanges="true"
                        android:background="@drawable/background_edittext"
                        android:visibility="gone">

                        <EditText
                            android:id="@+id/activeCaptionText"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_margin="10dp"
                            android:animateLayoutChanges="true"
                            android:background="@null"
                            android:hint="Say something about the photo you uploaded…"
                            android:textColor="#424447"
                            android:textColorHint="#8A8A8A"
                            android:textSize="12sp" />

                    </RelativeLayout>

                    <LinearLayout
                        android:id="@+id/afterCaptionState"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="20dp"
                        android:layout_marginTop="12dp"
                        android:animateLayoutChanges="true"
                        android:orientation="vertical"
                        android:visibility="gone">

                        <TextView
                            android:id="@+id/afterCaptionText"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="12dp"
                            android:animateLayoutChanges="true"
                            android:textColor="#F0F0E9"
                            android:textSize="12sp" />

                        <TextView
                            android:id="@+id/editCaptionButton"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:animateLayoutChanges="true"
                            android:text="EDIT"
                            android:textColor="#F0F0E9"
                            android:textSize="10sp" />

                    </LinearLayout>

                </RelativeLayout>

            </LinearLayout>

            <RelativeLayout
                android:id="@+id/nextButton"
                android:layout_width="match_parent"
                android:layout_height="32dp"
                android:layout_marginBottom="20dp"
                android:animateLayoutChanges="true"
                android:background="@drawable/button_background">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:animateLayoutChanges="true"
                    android:text="NEXT"
                    android:textColor="#F0F0E9"
                    android:textSize="10sp" />

            </RelativeLayout>

        </LinearLayout>

    </ScrollView>

</RelativeLayout>

I want the header part (Add Photo and cross image) to remain at top and the rest of the content to be scrollable. The image is displayed as SimpleDraweeView. Note that there are some elements below the image, but I am not able to scroll to see them.

Amit Tiwari
  • 3,684
  • 6
  • 33
  • 75

2 Answers2

0

try adding:

<ScrollView android:id="@+id/scroll_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"  //change here
    android:fillViewport="true" >  //add this
rafsanahmad007
  • 23,683
  • 6
  • 47
  • 62
0

Figured it out, it was my own mistake. I had written this in my activity

scrollView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (activeLocationState.getVisibility() == View.VISIBLE && !TextUtils.isEmpty(currentlocation)) {
                    activeLocationState.setVisibility(View.GONE);
                    afterLocationState.setVisibility(View.VISIBLE);
                    afterLocationText.setText(currentlocation);
                }

                if (activeCaptionState.getVisibility() == View.VISIBLE) {
                    currentCaption = activeCaptionText.getText().toString().trim();
                    if (!TextUtils.isEmpty(currentCaption)) {
                        activeCaptionState.setVisibility(View.GONE);
                        afterCaptionState.setVisibility(View.VISIBLE);
                        afterCaptionText.setText(currentCaption);
                    }
                }

                return true;
            }
        });

This was consuming all the touch events. To fix this, I moved the touch logic to the LinearLayout that is inside the ScrollView.

Amit Tiwari
  • 3,684
  • 6
  • 33
  • 75