Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inside CollapsingToolbarLayout ImageView Click event is not trigger Android

Tags:

android

Image View inside CollapsingToolbarLayout , but click event is not triggering. How to to solve this issue.

like image 266
Kanaga Durga Avatar asked Oct 03 '15 09:10

Kanaga Durga


1 Answers

Just make sure you don't have any view above the layout. In my case I had a toolbar and it was eating the clicks.

        <android.support.design.widget.CollapsingToolbarLayout
        >

        <include...
            />
        <android.support.v7.widget.Toolbar...
            />
        <android.support.design.widget.TabLayout...
            />

    </android.support.design.widget.CollapsingToolbarLayout>

I had to create a new Class extending toolbar that let clicks go through it(How to click views behind a Toolbar?)

public class NonClickableToolbar extends Toolbar {

    @Override
        public boolean onTouchEvent(MotionEvent ev) {
        return false;
    }
}
like image 143
Javier Avatar answered Oct 11 '22 15:10

Javier