Android 如何使视图下的视图可单击?
我将“回收器”视图滚动到工具栏顶部,但工具栏项目(如“主页”按钮)不可单击 我的布局:Android 如何使视图下的视图可单击?,android,android-layout,Android,Android Layout,我将“回收器”视图滚动到工具栏顶部,但工具栏项目(如“主页”按钮)不可单击 我的布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/primary">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/primary">
<include
android:id="@id/toolbar_feed"
layout="@layout/toolbar_feed"/>
// Inside viewPager is recycler view which scroll over the toolbar
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include
android:id="@+id/navigation_bottom_layout"
layout="@layout/bottom_navigation_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
我唯一的问题是工具栏主页按钮不可点击,因为它位于viewPager层后面。它可以用于播放translationZ,但它只支持API21+。那么,你们有办法让这项工作顺利进行吗?更改在其父视图中添加视图的顺序
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/primary">
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<include
android:id="@id/toolbar_feed"
layout="@layout/toolbar_feed"/>
<include
android:id="@+id/navigation_bottom_layout"
layout="@layout/bottom_navigation_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
你试过android:clickable=true吗?@okset是的,它不起作用。你能发布整个xml布局吗?它不是我用例的解决方案。我需要在工具栏上滚动的回收器。在您的示例中,点击拦截可以,但工具栏将位于我的回收器视图上方。您提到了回收器视图,但我在您的布局中没有看到它。如果不发布与您的问题xml文件相关的所有内容,就很难提出解决方案。抱歉,在编辑问题之前,有一条评论,我解释了viewpager中的是recycler视图。总之,您希望RecyclerView位于工具栏顶部,但同时希望单击事件由工具栏按钮而不是RecyclerView项使用。后一个项目是否可以单击?我希望工具栏和回收器视图项目可以同时单击,但回收器必须位于工具栏上方。我已经做了一些变通办法,制作了透明视图,并将其放置在viewpager上方home按钮所在的位置。