0

I am having a weird issue which might be very simple to solve but I don't know why its behaving like it does. I have two screens A and B. Navigation is from A -> B. On B, I have parent view as LinearLayout (LL) as

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:id="@+id/container"
    android:orientation="vertical"
    android:background="@color/tcRaspberry"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:animateLayoutChanges="true"
    android:layout_height="match_parent">

<include
        app:layout_constraintBottom_toTopOf="@+id/bottomSheetContainer"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        android:id="@+id/toolbarx"
        layout="@layout/include_toolbarx"/>

<androidx.constraintlayout.widget.ConstraintLayout
        android:layout_marginStart="@dimen/itinerary_start_margin"
        android:layout_marginEnd="@dimen/itinerary_start_margin"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <androidx.appcompat.widget.AppCompatImageView
            android:contentDescription="@null"
            app:layout_constraintTop_toTopOf="parent"
            android:layout_marginTop="@dimen/itinerary_start_margin"
            app:layout_constraintStart_toStartOf="parent"
            android:id="@+id/myAccountImage"
            android:layout_gravity="center"
            app:srcCompat="@drawable/ic_panorama_circle_24dp"
            android:layout_width="@dimen/image_size_profile"
            android:layout_height="@dimen/image_size_profile"/>

    <androidx.appcompat.widget.AppCompatTextView
            android:textSize="20sp"
            android:contentDescription="@string/travel_counsellor_contact"
            android:layout_marginStart="@dimen/top_margin"
            app:layout_constraintTop_toTopOf="@+id/myAccountImage"
            app:layout_constraintStart_toEndOf="@+id/myAccountImage"
            app:layout_constraintBottom_toBottomOf="@+id/myAccountImage"
            android:id="@+id/myAccountTitle"
            android:textAppearance="@style/TcTextAppearance.Bold.Header"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/my_account"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

Even though the parent LL's height (id: container) is set as match_parent and is filling whole screen, its still accepting click events from previous screen A. The only way I got it to not accept clicks from A is to put a ClickListener on it which seems like a hack to me. What can I do to prevent it taking clicks from A.

saintjab
  • 1,626
  • 20
  • 31
  • If backgrounds of both LL are same can you change to see the actual height of the child LL? – faranjit Aug 15 '19 at 10:39
  • @faranjit, I tried that. The second screen fills the whole screen so I pretty sure match_parent is working, just not sure why its capturing clicks from previous screen. – saintjab Aug 15 '19 at 10:44

1 Answers1

1

Make the view that should block the call clickable via xml android:clickable="true" or set a click handler for it from fragment/activity

Maksym V.
  • 2,877
  • 17
  • 27
  • That works but as it feels more like a hack to me. Any other explanation to why match_parent is filling viewport but still taking clicks from under views? – saintjab Aug 15 '19 at 10:39
  • take a look here https://stackoverflow.com/questions/19676712/pass-touches-to-the-view-under – Maksym V. Aug 15 '19 at 10:55