nirhart / ParallaxScroll

Parallax ScrollView and ListView for Android
MIT License
847 stars 187 forks source link

Parallax View click listener problems #47

Closed adnan-SM closed 9 years ago

adnan-SM commented 9 years ago

I am using your library for parallax views, so I have a Imageview at the top & a linear layout below it. I need the linear layout to parallax on top of the imageview. It works fine , but the click listeners get messed up. Clicking on imageviews in the linear layout don't register clicks they rather go to the parallaxed imageview behind it.

My Layout :


<com.nirhart.parallaxscroll.views.ParallaxScrollView
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     app:parallax_factor="1.5"
     app:alpha_factor="1.0"
     tools:context=".DetailActivity" >

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    xmlns:fresco="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/rootLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.test.dribbbleapp.ui.activities.DetailActivity">

        <ImageView
            android:id="@+id/detailView"
            android:layout_width="match_parent"
            android:layout_height="400dp"
         />

        <View   android:id="@+id/dividerLayout"
                android:layout_width="fill_parent"
                android:layout_height="2dp"
                android:layout_below="@id/detailView"
                android:layout_marginTop="-41dp"
                android:background="@color/style_color_primary_dark"/>

        <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:layout_below="@id/detailView"
                android:id="@+id/headerLayout"
                android:layout_marginTop="-40dp"
                android:background="@color/style_color_primary">

            <ImageView android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       android:layout_centerVertical="true"
                       android:id="@+id/ivComments"
                       android:layout_marginLeft="32dp"
                       android:src="@drawable/ic_comment_outline_grey"/>

            <TextView android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:id="@+id/tvCommentCount"
                      android:text="134"
                      android:layout_marginLeft="16dp"
                      android:layout_centerVertical="true"
                      android:layout_toRightOf="@id/ivComments"/>

            <ImageView android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       android:id="@+id/ivLikes"
                       android:layout_centerVertical="true"
                       android:src="@drawable/ic_heart_outline_grey"
                       android:layout_marginLeft="32dp"
                       android:layout_toRightOf="@id/tvCommentCount"/>

            <TextView android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:id="@+id/tvLikesCount"
                      android:layout_marginLeft="16dp"
                      android:text="45"
                      android:layout_centerVertical="true"
                      android:layout_toRightOf="@id/ivLikes"/>

        </RelativeLayout>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:id="@+id/tvDescription"
            android:layout_below="@id/headerLayout"/>

        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/tvTags"
                android:layout_below="@id/tvDescription"/>

    </RelativeLayout>
</com.nirhart.parallaxscroll.views.ParallaxScrollView>

Any ideas what I am doing wrong ?

Edit : The image click listeners work well but clicking anywhere else on the layout causes the click to go to the background imageview.

Thanks

adnan-SM commented 9 years ago

Made the layout clickable true and it works as expected!