简体   繁体   English

设计支持库,工具栏按钮裁剪波纹

[英]Design Support Library, Toolbar buttons cropped ripple

I'm trying to utilize the CoordinatorLayout, AppBarLayout, CollapsingToolbarLayout, Toolbar and a parallax'ed ImageView .我正在尝试利用CoordinatorLayout, AppBarLayout, CollapsingToolbarLayout, Toolbar和视差处理的ImageView It looks like the ripple effect of the toolbar menu items is cropped.看起来工具栏菜单项的涟漪效果被裁剪了。 The following image displays the ripple effect of the back button in expanded and in partially collapsed mode.下图显示了后退按钮在展开和部分折叠模式下的涟漪效果。 In complete collapsed mode the ripple effect is not shown at all.在完全折叠模式下,根本不显示涟漪效应。 I think this is caused by the parallax'ed ImageView that is positioned there.我认为这是由定位在那里的视差ImageView引起的。

在此处输入图片说明

Layout:布局:

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.view.ViewPager
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
    </android.support.v4.view.ViewPager>

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="224dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:weightSum="1.0">

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="56dp"
            android:layout_weight="1.0"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="48dp"
                android:scaleType="centerInside"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.4"/>

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

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

        <android.support.design.widget.TabLayout
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:background="@color/transparent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:tabGravity="fill"
            app:tabMode="fixed"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>

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

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

The ImageView displays a 9-patch 'ed Image. ImageView显示一个9-patch 'ed Image。 Is there something wrong with the layout or is it a bug/inability in the design support library to draw the ripple ontop of the ImageView?布局有问题还是设计支持库中的错误/无法在 ImageView 上绘制波纹?

I think your solution is here .我认为您的解决方案就在这里

You can try to add this line:您可以尝试添加此行:

<item name="actionBarItemBackground">?attr/selectableItemBackground</item>

in the theme/style of your Toolbar.在工具栏的主题/样式中。

If it doesn't work, add this in your Toolbar attributes:如果它不起作用,请将其添加到您的Toolbar属性中:

android:background="@android:color/transparent"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Android支持设计库在工具栏上苦苦挣扎 - Struggling with toolbar using android support design library 隐藏滚动设计支持库上的工具栏 - Hide toolbar on scroll design support library (设计支持库)CollapsingToolbarLayout - 工具栏在崩溃时没有固定 - (Design Support Library) CollapsingToolbarLayout — Toolbar not getting pinned on collapse (设计支持库)状态栏后面的工具栏项 - (Design Support Library) Toolbar items behind the status bar 使用Android设计支持库平滑动画折叠工具栏 - Smooth animated Collapsing Toolbar with Android Design Support Library 使用Android设计支持库的工具栏间距问题 - Toolbar spacing issue using Android Design Support Library 设计库和支持库 - Design library and support library 如何使用支持库实现波纹动画? - How to achieve ripple animation using support library? Android:从支持库向“工具栏”小部件添加操作按钮的正确方法是什么? - Android: What is the proper way to add action buttons to the Toolbar widget from the Support Library? Android设计支持库:使用ViewPager / TabLayout和滚动工具栏以及粘滞按钮 - Android Design Support Library: Use ViewPager/TabLayout with scrolling toolbar and sticky button
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM