Android同样的布局文件,在4.4上无法显示Toobar,5.0可以。
本文介绍了Android同样的布局文件,在4.4上无法显示Toobar,5.0可以。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
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"
看看
这篇关于Android同样的布局文件,在4.4上无法显示Toobar,5.0可以。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文