Android: nested links inside of clickable layout
Here's scenario:
- I have a
RalativeLayout
holdingImageView
and fewTextViews
. - There are "linkified" elements inside these
TextViews
such as URLs, phone numbers, etc. - Clicking on the links result in various actions, also clicking on ImageView triggers some action too.
- Now - I want to have outer onClick attached to th开发者_JS百科e complete area of
RelativeLayout
in such way that if user clicks on any spot withing the layout (but outside of the image and links) then it executes another action
Right now I have layout#onClick
, image#onClick
, and embedded links are processed by Linkify. Image and links clicks are working reliably but clicks on layout are captured about 50% of the time and I suppose would frustrate users to the point of tears. Any tricks that you guys can suggest to improve reliability? And if not what would be a good way of achieving this from the best usability standpoint?
Since no one came out with answer at least I can share my thoughts about the solution. Basically I decided not to fight overlapping click handlers and instead, start with onClick
enabled on the parent. Then, when the parent detects the click it turns it's own focus off and lets other controls take care of clicks. I also added "Off" button that is visible only when parent is expanded and clicking on that collapses the parent and puts the focus back into the parent view.
Let me know if you know better solution
精彩评论