I'm trying to achieve the scrolling Toolbar
technique (hiding Toolbar
when scrolling down in a sibling child view) using CoordinatorLayout
and AppBarLayout
.
I'm using Crosswalk's XWalkView (it's a view which functions like WebView).
When using regular WebView (inside a NestedScrollView
) I can achieve the wanted effect:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/webViewOrig"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
However when using the XWalkView
in the same way, I can't get it to work.
After using the following XML layout:
<android.support.v4.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport = "true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<org.xwalk.core.XWalkView
android:id="@+id/webViewCross"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.NestedScrollView>
the view doesn't even appear.
When removing the following line
app:layout_behavior="@string/appbar_scrolling_view_behavior"
the XWalkView
is at least displayed but on the whole screen and on top of the Toolbar.
What should I do to make it work? Since it's an open-source I should be able to make it work... I suspect it's either subclass XWalkView
and implement some interface (NestedScrollingChild
?) or creating a custom behaviour by subclassing CoordinatorLayout.Behavior
or AppBarLayout.ScrollingViewBehavior
.
Any ideas?
BTW XWalkView
is using internally either SurfaceView or TextureView to render the web content.