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就能隐藏

工具栏的
相关问题