0

我想要一個隱形工具欄,但我希望顯示後退箭頭和標題。工具欄不能正確隱藏。請參閱詳細信息

爲了實現這一點,我做了以下內容:

<?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" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="com.abc.xyz.AboutActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay" 
     android:background="@color/toolbarTransparent"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize"/> 

    </android.support.design.widget.AppBarLayout> 

    <FrameLayout 
     android:id="@+id/header_about" 
     android:layout_width="match_parent" 
     android:layout_height="160dp" 
     android:background="@color/colorAccent"/> 

    <ImageView 
     android:id="@+id/a" 
     android:layout_width="match_parent" 
     android:layout_height="70dp" 
     android:src="@drawable/a" 
     app:layout_anchor="@id/header_about" 
     app:layout_anchorGravity="bottom|center"/> 

    <include layout="@layout/content_about"/> 

</android.support.design.widget.CoordinatorLayout> 

但是,我得到以下結果(看工具欄怎麼還出現在那裏):

我希望工具欄變得不可見,只顯示標題和後退箭頭。

請讓我知道我該如何實現這一目標。

對不起,問題的格式不好。我仍然是這裏的初學者。

+0

設置背景透明會做的伎倆爲您 –

回答

1

AppBarLayout具有默認的高程值,這就是爲什麼你可以看到陰影。你可以設置AppBarLayout標高爲0dp

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay" 
    app:elevation="0dp" 
    android:background="@color/toolbarTransparent"> 

或者只是刪除AppBarLayout。工具欄默認是透明的。

如果你想在Android棒棒糖版本和更大的透明背景使用AppBarLayout - 設置輪廓提供商背景象下面這樣:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
    appBarLayout.setOutlineProvider(ViewOutlineProvider.BACKGROUND); 
} 

在這種情況下,當你的背景是透明的陰影將是不可見的。

+1

做'應用:海拔=「0dp」 '使標題和後退箭頭消失。 –

0

請檢查Android清單文件時,它應該有AppTheme.NoActionBar則u就能隱藏

工具欄的
相關問題