Using hierarchyviewer in a Gmail conversation view shows an interesting and unusual layout hierarchy:
- All messages in one session are displayed in one WebView (in particular,
com.google.android.gm.CustomWebView
, see left). Only the message body is displayed - the spaces in which the headers are placed remain empty . - At the top of the WebView is superimposed
com.google.android.gm.MessageHeaderScrollView
(see right), which uses the HybridConversationScrollContainer
to place a MessageHeaderView
in the correct position for each message in the conversation view.
↔ ![MessageHeaderScrollView](https://fooobar.com//img/9aac1949f436b8ba58cc0b3ff5ef135c.png)
So how (and why) is this achieved? Is this something that an Android developer could and should strive to recreate in its applications?
Obviously, the likely cause is performance. WebView uses WebKit's own fast visualization of the message body, and one WebView is probably more efficient than a separate WebView for each message. If anyone saw a good blog post about the performance benefits of this, I would be interested.
However, there is obvious difficulty for this approach (against the naive use of an ExpandableListView with some text elements inside it or something else) - the HybridConversationScrollContainer
must somehow figure out where the message headers should go through the web rendering in order to correctly position its MessageHeaderViews
. I would like to know how this works:
source share