【发布时间】:2018-03-13 18:40:51
【问题描述】:
在我的活动中,我使用 bottom sheet 布局 - 即带有 ID bottom_sheet 的 NestedScrollView。
在 NestedScrollView 中,我有 LinearLayout,其中包含另一个布局 (layout_player)。
<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.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/cl_root"
>
<some layouts here />
</android.support.constraint.ConstraintLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="100dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
android:visibility="invisible"
>
<LinearLayout
android:id="@+id/player_container"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_gravity="bottom"
>
<include layout="@layout/layout_player"
/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
包含的layout_playerlayout 由带有一些 Guidelines 的 ConstraintLayout 和带有 ImageView 的 RelativeLayout 组成。
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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="100dp"
>
...
<RelativeLayout
android:id="@+id/rl_play"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="@id/guidelineTop"
app:layout_constraintBottom_toBottomOf="@id/guidelineBottom"
app:layout_constraintDimensionRatio="H,1:1"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@drawable/ic_play"
/>
</RelativeLayout>
...
</android.support.constraint.ConstraintLayout>
在我为布局 layout_player 中的视图设置 clickListeners 之后 - 具有 ID player_container 的父 LinearLayout 消耗其子级的所有点击。但我需要孩子的点击事件 - 而不是父母。
如何在其父级中启用点击子级?
在我的情况下,如何获取位于 LinearLayout 内的 ContraintLayout 内的 RelativeLayout 的点击事件?
【问题讨论】:
标签: android android-layout android-view bottom-sheet