Serhii Tereshchenko
Serhii Tereshchenko

Reputation: 197

Scroll ScrollView over ImageView

I need to scroll content in ScrollView over a static ImageView above ScrollView. When ImageView will dissappear, ScrollView need to scroll normally. The effect is same as with CollapsingToolbarLayout, but I need to do it without using actionbar and without effects.

Like here - https://www.youtube.com/watch?t=23&v=FTRpemXF3_8

My layout file:

<ImageView
    android:id="@+id/full_image"
    android:layout_width="match_parent"
    android:layout_height="@dimen/full_image_height"
    android:scaleType="centerCrop"
    android:src="@mipmap/logo" />

<ScrollView
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="@dimen/full_image_height">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:elevation="8dp"
        android:padding="@dimen/text_margin">

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginBottom="@dimen/small_margin"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/date"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_below="@+id/title"
            android:text="Small Text"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <TextView
            android:id="@+id/time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/title"
            android:layout_marginLeft="@dimen/small_margin"
            android:layout_toEndOf="@+id/date"
            android:layout_toRightOf="@+id/date"
            android:text="Small Text"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="@color/colorAccent" />

        <TextView
            android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_below="@+id/date"
            android:layout_marginTop="@dimen/small_margin"
            android:text="Medium Text"
            android:textAppearance="?android:attr/textAppearanceMedium" />

    </RelativeLayout>

</ScrollView>

Upvotes: 1

Views: 842

Answers (1)

Ankush Sharma
Ankush Sharma

Reputation: 933

If i understand it correctly from your description and from the youtube link that you provide, i think this library will work for you, https://github.com/umano/AndroidSlidingUpPanel . Its an amazing library where you can define your two layout one could be a layout which will have the image view in full screen and other could be the layout with your scrollview. This way you can have exactly same effect you are looking for. Moreover, you can control your scrollview layout and can have it settle like in middle of the screen or at the bottom. User can drag it up to full screen or can leave it pinned in the middle. Give it a shot, let us know if you have any difficulty.

Upvotes: 1

Related Questions