emilsjolander / android-FlipView

A small, easy to use android library for implementing flipping between views as seen in the popular Flipboard application
Apache License 2.0
924 stars 273 forks source link

Scroll for long content #32

Closed rafaelekol closed 10 years ago

rafaelekol commented 10 years ago

In my project some content is long, so it needs scrolling to be viewed. For android-FlipView I use this item layout

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <RelativeLayout
        android:id="@+id/RalativeLayout01"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginBottom="30dp"
        android:background="#dfdfdf" >

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:maxWidth="600dp"
            android:padding="5dp"
            android:paddingBottom="1dp"
            android:textColor="#615F5C"
            android:textSize="35sp" />

        <ImageView
            android:id="@+id/newsImage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/title"
            android:layout_centerHorizontal="true"
            android:adjustViewBounds="true"
            android:contentDescription="@string/img_dsc"
            android:maxWidth="600dp" />

        <TextView
            android:id="@+id/contentTxt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/newsImage"
            android:layout_centerHorizontal="true"
            android:maxWidth="600dp"
            android:padding="5dp"
            android:paddingBottom="1dp"
            android:textColor="#615F5C"
            android:textSize="19sp" />
    </RelativeLayout>

</ScrollView>

Problem here is that when I scroll one content to bottom and then flip to another content and then back this page in same state(shows the bottom side of content) How I can fix it? I need to show always the top of content when flipping.

emilsjolander commented 10 years ago

You could attach a OnFlipListener and reset the scroll position of your view when it is flipped to.

As a side note i would advice not doing this from a user experience point of view because the user probably expects the view to be in the same position as it was left in.

rafaelekol commented 10 years ago

Good point about User Experience. I think I will leave it as it is. Thank you.