1

So I tried the solution in this post: Spotify ListView header image effect in the app I'm currently developing.

Everything is working fine except for one small issue, I cannot make the background views handle the clicks. Here's what I mean in detail

The layout for the activity implementing the parallax effect is the following:

<ParallaxScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/parallaxScrollView"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="?white">

    <LinearLayout
      android:id="@+id/parallaxScrollViewBackground"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical">

        <View
          android:layout_width="match_parent"
          android:layout_height="3dp"
          android:background="@color/yellow" />

       <include
          android:layout_width="match_parent"
          android:layout_height="48dp"
          layout="@layout/layout1" />

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

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

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

      <include layout="@layout/layout5" />
    </LinearLayout>

    <ParallaxLinearLayout
      android:id="@+id/parallaxScrollViewForeground"
      android:layout_width="match_parent"
      android:layout_height="wrap_content">

        <LinearLayout
          android:id="@+id/llMainHolder"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical">

            <LinearLayout
              android:id="@+id/llMain"
              android:layout_width="match_parent"
              android:layout_height="wrap_content">

                <ListView
                  android:id="@+id/content_list"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:background="?white"
                  android:divider="@android:color/transparent"
                  android:dividerHeight="20dp"
                  android:cacheColorHint="#00000000"
                  android:listSelector="@android:color/transparent"
                  android:overScrollMode="never"
                  android:scrollbars="none" />

            </LinearLayout>

        </LinearLayout>

    </ParallaxLinearLayout>

</ParallaxScrollView>

The ParallaxLinearLayout is the same as AnotherView in the solution presented in the answer I mentioned before.

As you see, parallaxScrollViewBackground, holds a lot of layouts. These layouts should handle some click events. However, the foreground (ParallaxLinearLayout) is actually the one receiving and handling the clicks (I checked through the debugger and with a bit of logging help).

So my question: Is there a way to send the click events to the background views with my current setup? If not, I'm open to suggestions.

Thanks

Community
  • 1
  • 1
Fred
  • 16,367
  • 6
  • 50
  • 65

1 Answers1

0

Try android:clickable="false" on the ParallaxScrollView and android:clickable="true" on the LinearLayouts. Then when you initialise set up an onClickListener for the LinearLayouts.

alex
  • 12
  • 1