4

I am using a Fragment in my android app. This Fragment does not have it's own Toolbar or android.support.v7.widget.Toolbar element, but rather uses getSupportActionBar() from it's parent activity. Now, I want to set up Parallax Scrolling of the ScrollView over infoRL.

I checked some resources online, but most of them are about Parallax a ScrollView over an ImageView, or use Toolbars in the layout.

So I was wondering how I can go about structuring them.

Here is how my layout.xml file is structured.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<include
    layout="@layout/custom_toolbar"/>

<LinearLayout
    android:id="@+id/infoRL"
    android:orientation="vertical"
    android:paddingTop="40dp"
    android:layout_width="match_parent"
    android:paddingBottom="40dp"
    android:layout_height="wrap_content"
    android:background="@color/treasur_yellow"
    android:layout_below="@+id/custom_toolbar_element">


    <com.joooonho.SelectableRoundedImageView
        android:id="@+id/profileImageView"
        android:layout_width="128dp"
        android:layout_gravity="center_horizontal"
        android:layout_height="128dp"
        android:layout_centerHorizontal="true"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        app:sriv_left_bottom_corner_radius="0dp"
        app:sriv_oval="true"
        app:sriv_right_bottom_corner_radius="0dp" />


    <hunt.ayush.com.traserhunt.utility.CentuaryGothicTextView
        android:id="@+id/userName"
        android:layout_gravity="center_horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageBorderLayout"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="15dp"
        android:text="Fetching Name"
        android:textColor="@color/treasure_black"
        android:textSize="20sp" />

    </LinearLayout>

    <ScrollView />
</RelativeLayout>
Ayush Gupta
  • 8,716
  • 8
  • 59
  • 92
  • Could you please try with coordinator layout and collapsable layout inside fragment layout . and then hide toobar. – Chayan Chowdhury Nov 19 '16 at 13:37
  • I could but thats unnecessary resource usage. I'm trying to find the most optimized may or I'll fall back to that as a backup plan – Ayush Gupta Nov 19 '16 at 13:40
  • create a coordinator layout as top level layout and add appbar layout as first child. Inside that add collapsing toolbar layout and then put your linear layout (which has image) inside that. now you can use collapse mode parallex on imageview. Also put your scrollview as second child of your parent coordinator layout and add layout_behavior="@string/appbar_scrolling_view_behavior" as behaviour to scrollview. – Ankit Aggarwal Nov 25 '16 at 07:15

1 Answers1

1
Please try with frame layout once

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

<ImageView
    android:id="@+id/heroImageView"
    android:layout_width="match_parent"
    android:layout_height="250dp"
    android:background="@drawable/wallpaper"
    android:scaleType="fitCenter" />

<ListView
    android:id="@+id/listView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:divider="#9E9E9E"
    android:dividerHeight="1dp"
    android:scrollbars="none"></ListView>

<TextView
    android:id="@+id/stickyView"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="#222"
    android:gravity="center_vertical"
    android:paddingLeft="10dp"
    android:text="Heading1"
    android:textColor="#fff"
    android:textSize="20sp"
    android:textStyle="bold" />