Борьба с панелью инструментов с использованием библиотеки дизайна поддержки Android

Я пытаюсь получить прозрачную панель инструментов, а RecyclerView содержит пользовательский относительный макет, который я назвал customHeader . мой макет в основной деятельности выглядит так:

я использую библиотеку дизайна поддержки Android v.22.2.1 и другие библиотеки поддержки с той же версией, все в порядке, за исключением того, что я получаю панель инструментов с моим основным цветом, а не с прозрачной панелью инструментов, хотя я удалил цвет фона из макета панели инструментов.

вот результат, который я получил: введите здесь описание изображения

Мне нужна прозрачная панель инструментов, но она должна заполняться основным цветом только при прокрутке вверх

мой макет activity_main:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/rootLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">
        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
           >
        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsingToolbarLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            >

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:layout_scrollFlags="scroll|enterAlways"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

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

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

        <FrameLayout
            android:id="@+id/content_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/btnCreate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:layout_marginBottom="@dimen/btn_fab_margins"
            android:layout_marginRight="@dimen/btn_fab_margins"
            android:src="@drawable/share"
            app:borderWidth="0dp"
            app:elevation="6dp"
            app:pressedTranslationZ="12dp" />
    </android.support.design.widget.CoordinatorLayout>


    <android.support.design.widget.NavigationView
        android:id="@+id/vNavigation"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/WHITE"
        app:itemIconTint="@color/primary_text"
        app:itemTextColor="@color/primary_text"
        app:headerLayout="@layout/drawer_header"
        app:menu="@menu/drawer_menu"/>
</android.support.v4.widget.DrawerLayout>

тогда макет в моем фрагменте:

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

    <!-- Story list in main page -->
    <com.creativeLabs.news.util.MySwipeRefreshLayout
        android:id="@+id/swipe_refresh_story"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity$PlaceholderFragment">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/list_view_story_list"
            android:overScrollMode="never"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </com.creativeLabs.news.util.MySwipeRefreshLayout>
</RelativeLayout>

мой макет customHeader:

<?xml version="1.0" encoding="utf-8"?>
<com.creativeLabs.news.ui.view.SlideTopStory
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_marginBottom="@dimen/story_list_item_margin_vertical"
    android:layout_width="match_parent"
    android:layout_height="@dimen/slide_image_height">

        <ImageView
            android:id="@+id/ivStoryimage"
            android:contentDescription="@string/story_title"
            android:scaleType="centerCrop"
            android:layout_width="match_parent"
            android:layout_height="match_parent"

            />

        <ProgressBar
            android:id="@+id/loading_bar"
            android:layout_centerInParent="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <!-- A mask view -->
        <View
            android:background="@drawable/title_slide_background"
            android:layout_alignParentBottom="true"
            android:layout_width="match_parent"
            android:layout_height="70dip"/>
        <View
            android:background="@drawable/title_slide_background1"
            android:layout_alignParentTop="true"
            android:layout_width="match_parent"
            android:layout_height="70dip"/>

        <TextView
            android:id="@+id/title"
            android:layout_alignParentBottom="true"
            android:textColor="@android:color/white"
            android:textSize="@dimen/text_size_large"
            android:gravity="center_vertical"
            android:paddingLeft="@dimen/slide_image_title_padding"
            android:paddingRight="@dimen/slide_image_title_padding"
            android:paddingEnd="@dimen/slide_image_title_padding"
            android:layout_marginBottom="@dimen/slide_image_title_margin"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

</com.creativeLabs.news.ui.view.SlideTopStory>

Мое приложение thems.xml:

  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="colorControlNormal">@android:color/white</item>
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    .......
    .......

in the manifest -> application tag:
android:theme="@style/AppTheme.WithoutActionBar">   

в моих действиях и фрагментах я ничего не закодировал в отношении цветов панели инструментов или каких-либо других обработок, кроме

setSupportActionBar(toolbar);
    getSupportActionBar().setHomeButtonEnabled(true);
    toolbar.setNavigationIcon(getActionBarIconResource());

Итак, почему панель инструментов получает основной цвет приложения? как я могу получить прозрачную панель инструментов .. помогите, пожалуйста? заранее спасибо


person Fshamri    schedule 01.08.2015    source источник


Ответы (1)


<android.support.v7.widget.Toolbar  
 app:popupTheme="@style/ThemeOverlay.AppCompat.Light"  
 app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />   

Проверьте, как применяется стиль u

Где вы установили прозрачность (альфа?)

View.getBackground().setAlpha(..) ;
person ceph3us    schedule 01.08.2015
comment
я перешел по этой статье по ссылке, где он только что удалил панель инструментов background (android:background=?attr/colorPrimary), поэтому, думаю, нет необходимости устанавливать альфа-канал фона на 0. в чем ошибка в моем примененном стиле? - person Fshamri; 01.08.2015
comment
@ user2198400 без трассировки выполнения кода и полного исходного кода я не могу этого сказать. Попробуйте получить панель инструментов и установить альфа-канал, это сделает все, что вам нужно - я имею в виду установить прозрачный цвет (полная альфа-версия) - person ceph3us; 01.08.2015
comment
ценю ваш вклад - person Fshamri; 01.08.2015