Прозрачная панель инструментов серого цвета - PullRequest
0 голосов
/ 07 мая 2019

Что я делаю не так?Мой минимальный уровень API равен 21. Я пытаюсь сделать панель инструментов прозрачной:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

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

    <!-- Content -->
    <FrameLayout
        android:id="@+id/frame_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/toolbar"
        android:background="@color/colorAccent" />
</RelativeLayout>

Это стиль:

<!-- Toolbar transparent -->
<style name="AppTheme.Toolbar.Transparent" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="android:windowActionBarOverlay">true</item>
    <item name="windowActionBarOverlay">true</item>
</style>

И вот результат:

Transaparent toolbar results gray

1 Ответ

0 голосов
/ 07 мая 2019

Вы поместили framelayout под панелью инструментов в относительное расположение. Приведенный ниже код решит вашу проблему.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:background="@color/colorAccent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <!-- Toolbar -->
    <android.support.v7.widget.Toolbar

        android:layout_alignParentTop="true"
        android:id="@+id/toolbar"
        style="@style/AppTheme.Toolbar.Transparent"
        or
        android:background="@android:color/transparent"  
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize" />

    <!-- Content -->
    <FrameLayout
        android:id="@+id/frame_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/toolbar"
        android:background="@color/colorAccent" />
</RelativeLayout>
...