无法在CollapsingToolbarLayout中单击项目

时间:2017-09-21 08:14:16

标签: android android-layout android-collapsingtoolbarlayout

我已经实现了CollapsingToolbarLayout,如下所示:

collapsing toolbar layout

滚动时会崩溃,但是存在一个大问题:我无法点击其中的项目(后退按钮,编辑按钮,编辑文本字段等)。没有任何项目对点击/触摸事件做出反应。

现在,"逻辑"以XML结构,具有以下结构:

    <CoordinatorLayout>
     <AppBarLayout>
     <CollapsingToolbarLayout>
     <RelativeLayout/> here's where the panel layout sits 
     <Toolbar/>
     <NestedScrollView/>

  //close tags as appropriate here

如何使项目可点击(嗯,不是通过设置android:clickable="true"来确定)?是否可以在Java/Kotlin代码中编写听众?

1 个答案:

答案 0 :(得分:-1)

尝试添加此XML属性

android:descendantFocusability="blocksDescendants"

到您的CollapsingToolbarLayout