Inside CollapsingToolbarLayout ImageView Click event doesn't launch Android

View the image inside CollapsingToolbarLayout, but the click event does not fire. How to solve this problem.

+6
source share
5 answers

Just make sure you don't have a view over the layout. In my case, I had a toolbar and it eats 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 extension panel that extends the class, allowing clicks to go through it ( How to click on the screens behind the toolbar? )

 public class NonClickableToolbar extends Toolbar { @Override public boolean onTouchEvent(MotionEvent ev) { return false; } } 
+1
source

The question is not complicated enough, but it looks like this: ImageView consumes your click event.

try using

 ImageView.setOnClickListener(null); 

CollapsingToolbarLayout should receive click events. if this does not work, you know which line for google.

0
source

Try adding this XML attribute.

 android:descendantFocusability="blocksDescendants" 

for your CollapsingToolbarLayout

0
source

I also had this problem. It seems that clicks in the toolbar / application bar area do not work.

If your UI / UX allows, try placing the ImageView outside the toolbar area. For example, try putting it in line with the parent bottom. The click is expected to start. Worked for me (I worked with ImageButton , though, but pretty confidently ImageView should also work).

0
source

You can place the ImageView toolbar on top of the collapsible panel. I ran into the same problem. I selected it by placing the outside view of the crushing toolbar and tying it accordingly.

0
source

All Articles