2

I have the following layout.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="240dp"
            android:background="#123"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="Hello world"/>

    </LinearLayout>
</ScrollView>

enter image description here

I want to increase the size of ImageView as someone scrolls Down through ScrollView. And at particular time when the ImageView becomes enough large to scroll, I want to finish the activity. Any suggestions will be highly helpful.

Ajeet
  • 1,540
  • 1
  • 17
  • 30

1 Answers1

1

To achieve that effect you need to use a CoordinatorLayout so you have a header and hide it as you scroll.

Take a look at this: https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout

Eury Pérez Beltré
  • 2,017
  • 20
  • 28
  • I don't want to use CoordinatorLayout in my particular case. Also Coordinator layout does not extent after its predefined width and it does not support ScrollView I guess. – Ajeet Mar 04 '16 at 15:54
  • Well, you can try using one of these Parallax libraries: http://android-arsenal.com/tag/70 – Eury Pérez Beltré Mar 04 '16 at 15:59
  • Of course, I can use parallax for better animation. But all I want is increasing ImageView on down scroll of ScrollView. Anyway, I guess Coordinator Layout have parallax effect on its own. – Ajeet Mar 04 '16 at 16:03
  • Ok in that case you want to take a look to animations, using the scaleX() function you can increase the size. Check: http://developer.android.com/intl/es/reference/android/view/ViewPropertyAnimator.html – Eury Pérez Beltré Mar 04 '16 at 16:04
  • Yes, I want to use ViewPropertyAnimator but I want to know how and where I have to set values for scaleX(). Because I want to increase the size of ImageView as I scroll down not simultaneously. – Ajeet Mar 04 '16 at 16:06
  • You can check for the ScrollView scroll and update the scaleX() value accordingly. Check this post: http://stackoverflow.com/questions/10713312/can-i-have-onscrolllistener-for-a-scrollview – Eury Pérez Beltré Mar 04 '16 at 16:09
  • That's where the problems come. The onScrollChanged() callback does not call itself when you scroll down at top most position of the SrollView. – Ajeet Mar 04 '16 at 16:13