XML如下:
这样的一个布局,toolbar+webview:
<?xml version="1.0" encoding="utf-8"?>
<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/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_custom"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbarStyle="outsideOverlay" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_favorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_favorite_white_24dp"
app:layout_behavior="com.drunkpiano.zhihuselection.utilities.ScrollingFavoriteFABBehavior" />
</android.support.design.widget.CoordinatorLayout>
如果把最外层的CoordinatorLayout改成LinearLayout,Toolbar可以显示了,但FloatingActionBar就无法显示了。把CoordinatorLayout也不行。这是为什么?如何是好?
主题设置成了NoActionBar
这类样式看看,并将WebView设置一下这个属性app:layout_behavior="@string/appbar_scrolling_view_behavior"
看看