Android 如何使工具栏透明

Android 如何使工具栏透明,android,Android,我想使我的工具栏透明,但不知道如何? ` 您只需定义隐藏操作栏的主题,定义具有透明背景的操作栏样式,并将此样式设置为工具栏小部件。请注意,工具栏应作为最后一个视图(在所有视图树上)绘制 假的 真的 真的 真的 真的 布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_widt

我想使我的工具栏透明,但不知道如何? `


您只需定义隐藏操作栏的主题,定义具有透明背景的操作栏样式,并将此样式设置为工具栏小部件。请注意,工具栏应作为最后一个视图(在所有视图树上)绘制


假的
真的
真的
真的
真的
布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- Toolbar should be above content-->
    <include layout="@layout/toolbar" />

</RelativeLayout>

工具栏布局:

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:theme="@style/CustomActionBar"/>

您只需定义隐藏操作栏的主题,定义具有透明背景的操作栏样式,并将此样式设置为工具栏小部件。请注意,工具栏应作为最后一个视图(在所有视图树上)绘制


假的
真的
真的
真的
真的
布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- Toolbar should be above content-->
    <include layout="@layout/toolbar" />

</RelativeLayout>

工具栏布局:

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:theme="@style/CustomActionBar"/>