Android 高程为0dp的AppBarLayout不响应触摸事件(单击)

Android 高程为0dp的AppBarLayout不响应触摸事件(单击),android,material-design,android-coordinatorlayout,android-appbarlayout,Android,Material Design,Android Coordinatorlayout,Android Appbarlayout,我在我的应用程序中使用了AppBarLayout内部的CoordinatorLayout。由于某些设计要求,我被迫删除AppBarLayout元素下方的阴影,方法是将其高程属性设置为0。(app:elevation=“0”)。执行此操作后,AppBarLayout内的元素将不响应触摸/单击事件 通过将标高设置回1dp,元素会对触摸/单击事件做出响应,但随后我又恢复了阴影 当AppBarLayout处于0dp高程时,有人对如何使元素对触摸/点击事件作出响应提出建议吗 代码摘录: <and

我在我的应用程序中使用了
AppBarLayout
内部的
CoordinatorLayout
。由于某些设计要求,我被迫删除
AppBarLayout
元素下方的阴影,方法是将其高程属性设置为0。(
app:elevation=“0”
)。执行此操作后,AppBarLayout内的元素将不响应触摸/单击事件

通过将标高设置回1dp,元素会对触摸/单击事件做出响应,但随后我又恢复了阴影

AppBarLayout
处于
0dp
高程时,有人对如何使元素对触摸/点击事件作出响应提出建议吗

代码摘录:

  <android.support.design.widget.CoordinatorLayout
        android:id="@+id/rootLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="@dimen/app_bar_height"
            app:elevation="0dp">

            <android.support.v7.widget.Toolbar
                android:id="@+id/my_toolbar"
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:minHeight="?attr/actionBarSize">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="45dp"
                    android:scaleType="fitCenter"
                    android:layout_gravity="center"
                    android:id="@+id/toolbar_logo"
                    android:maxHeight="45dp"
                    android:contentDescription="Main logo"/>
            </android.support.v7.widget.Toolbar>

            <android.support.design.widget.TabLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:tabIndicatorColor="@color/tab_indicator_color"
                app:tabTextColor="@color/primary_text_grey"
                app:tabIndicatorHeight="3dp"
                android:id="@+id/tab_layout">
            </android.support.design.widget.TabLayout>

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

.......

通过将
坐标布局
元素替换为
线性布局
android:orientation=“vertical”
解决了这个问题。使用
CoordinatorLayout
似乎是一种错误的方法。

想结束这个循环,因为我遇到了一个非常类似的问题

问题不在于elevation=0dp,而在于CoordinatorLayout的行为类似于FrameLayout,这意味着稍后在XML中声明的元素与先前声明的元素“在顶部”。更改为线性布局碰巧起作用,因为它不支持“重叠元素”


正确的解决方案是将AppBarLayout(或任何元素)移动到拦截事件后声明的任何元素之上。当标高>0时,它起作用的原因是,在调度触摸事件时,会考虑标高,但如果标高相等,则会遇到相同的问题。

这很奇怪,但有效,我将FrameLayout改为LinearLayout,并且有效