Search code examples
javaandroidxmlscrollview

Android: ScrollView disables all buttons and navigation


I have a ScrollView on my page, but unfortunately it doesn't allow me to press other buttons like the upper-right and upper-left buttons to access the navigation drawers. This happens at all times on the page. When I start scrolling down, nothing works on the page itself, so I can't press any button or use the google maps API.

I know that this problem is linked to the ScrollView because I have 3 activities in my app that use ScrollView and they are the only ones where there is this problem.

Here is a screenshot that might help: the content of my current view overlaps the navigation bar, which might explain what the issue is.

overlapping

Here are the xml layouts:

activity_produit_detail.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">

<include
    layout="@layout/app_bar_produit_detail"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header_main"
    app:menu="@menu/activity_main_drawer" />

app_bar_produit_detail.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.adam_jaamour.cfimmobilier.Produits.ProduitDetail">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

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

<include layout="@layout/content_produit_detail" />

content_produit_detail.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">

    <!-- TITLE -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="50dp"
        android:orientation="horizontal"
        android:weightSum="1">

        <TextView
            android:id="@+id/txt_detail_title"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="fill"
            android:layout_weight="1"
            android:text="title"
            android:textColor="#101f34"
            android:textSize="20dp"
            android:textStyle="normal|bold" />

        <Button
            android:id="@+id/button_detail_heart"
            android:layout_width="39dp"
            android:layout_height="wrap_content"
            android:background="?android:attr/selectableItemBackground"
            android:drawableStart="@drawable/ic_star_border" />

    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="15dp"
        android:background="#FF000000" />

    <!-- RECYCLER VIEW -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="15dp"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/content_product_detail_recycer_view_cur_image"
            android:layout_width="150dp"
            android:layout_height="130dp"
            android:layout_gravity="center"
            android:background="@android:color/black" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/content_product_detail_recycer_view"
            android:layout_width="wrap_content"
            android:layout_height="60dp"
            android:layout_gravity="center"
            android:layout_margin="5dp"
            android:background="@android:color/darker_gray">

        </android.support.v7.widget.RecyclerView>

    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="15dp"
        android:background="#FF000000" />

    <!-- TITLE -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/txt_detail_price"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:text="price"
            android:textColor="#000000"
            android:textSize="16sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txt_detail_total_area_top"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:text="area"
            android:textColor="#000000"
            android:textSize="16sp"
            android:textStyle="bold" />
    </LinearLayout>

    <!-- IMAGES SCROLLABLE -->


    <!-- DESCRIPTION -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/txt_detail_description"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:text="description"
            android:textColor="#000000"
            android:textStyle="italic" />
    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="15dp"
        android:background="#FF000000" />

    <!-- REFERENCE -->
    <LinearLayout
        android:id="@+id/content_produit_detail_linear_layout_reference"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView100"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:text="@string/content_produit_detail_ref"
            android:textColor="#1b5cb4"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txt_detail_ref"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:text="null"
            android:textColor="#000000" />
    </LinearLayout>

    <!-- TYPE -->
    <LinearLayout
        android:id="@+id/content_produit_detail_linear_layout_type"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView101"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:text="@string/content_produit_detail_type"
            android:textColor="#1b5cb4"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txt_detail_type"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:text="null"
            android:textColor="#000000" />
    </LinearLayout>

    <!-- NUMBER OF ROOMS -->
    <LinearLayout
        android:id="@+id/content_produit_detail_linear_layout_nb_rooms"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView102"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:text="@string/content_produit_detail_nb_rooms"
            android:textColor="#1b5cb4"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txt_detail_nb_rooms"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:text="null"
            android:textColor="#000000" />
    </LinearLayout>

    <!-- TOTAL AREA -->
    <LinearLayout
        android:id="@+id/content_produit_detail_linear_layout_total_area_detail"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView103"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:text="@string/content_produit_detail_total_area"
            android:textColor="#1b5cb4"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txt_detail_total_area"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:text="null"
            android:textColor="#000000" />
    </LinearLayout>

    <!-- LIVING AREA -->
    <LinearLayout
        android:id="@+id/content_produit_detail_linear_layout_area_living"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView104"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:text="@string/content_produit_detail_living_area"
            android:textColor="#1b5cb4"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txt_detail_living_area"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:text="null"
            android:textColor="#000000" />
    </LinearLayout>

    <!-- TERRACE AREA -->
    <LinearLayout
        android:id="@+id/content_produit_detail_linear_layout_area_terrace"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView105"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:text="@string/content_produit_detail_terrace_area"
            android:textColor="#1b5cb4"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txt_detail_terrace_area"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:text="null"
            android:textColor="#000000" />
    </LinearLayout>

    <!-- BUILDING -->
    <LinearLayout
        android:id="@+id/content_produit_detail_linear_layout_building"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView106"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:text="@string/content_produit_detail_building"
            android:textColor="#1b5cb4"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txt_detail_building"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:text="null"
            android:textColor="#000000" />
    </LinearLayout>

    <!-- DISTRICT -->
    <LinearLayout
        android:id="@+id/content_produit_detail_linear_layout_district"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView107"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:text="@string/content_produit_detail_district"
            android:textColor="#1b5cb4"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txt_detail_district"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:text="null"
            android:textColor="#000000" />
    </LinearLayout>

    <!-- CITY -->
    <LinearLayout
        android:id="@+id/content_produit_detail_linear_layout_city"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView1070"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:text="Ville:"
            android:textColor="#1b5cb4"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txt_detail_city"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:text="null"
            android:textColor="#000000" />
    </LinearLayout>

    <!-- COUNTRY -->
    <LinearLayout
        android:id="@+id/content_produit_detail_linear_layout_country"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView10700"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:text="Country:"
            android:textColor="#1b5cb4"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txt_detail_country"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:text="null"
            android:textColor="#000000" />
    </LinearLayout>

    <!-- NUM PARKING -->
    <LinearLayout
        android:id="@+id/content_produit_detail_linear_layout_parking"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView1071"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:text="@string/content_produit_detail_parking"
            android:textColor="#1b5cb4"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txt_detail_parking"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:text="null"
            android:textColor="#000000" />
    </LinearLayout>

    <!-- NUM CELLAR -->
    <LinearLayout
        android:id="@+id/content_produit_detail_linear_layout_cellar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView1073"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left"
            android:text="@string/content_produit_detail_cellar"
            android:textColor="#1b5cb4"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txt_detail_cellar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:text="null"
            android:textColor="#000000" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="15dp"
        android:gravity="center_horizontal"
        android:orientation="horizontal">

        <Button
            android:id="@+id/content_product_detail_btn_mailCurProd"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="20dp"
            android:background="?android:attr/selectableItemBackground"
            android:drawableRight="@drawable/ic_mail"
            android:text="@string/content_produit_detail_button_send_product" />

        <Button
            android:id="@+id/content_product_detail_btn_mailAgency"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="?android:attr/selectableItemBackground"
            android:drawableRight="@drawable/ic_contact_mail"
            android:text="@string/content_produit_detail_button_send_info_agency" />
    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="15dp"
        android:background="#FF000000" />

    <fragment
        android:id="@+id/content_product_detail_gmaps"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="250dip"
        android:layout_margin="10dp" />


</LinearLayout>

</ScrollView>

Thanks in advance to anyone who might help.


Solution

  • Replace your ScrollView lines with below:

     <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      app:layout_behavior="@string/appbar_scrolling_view_behavior">
    

    And if possible, try to use NestedScrollView instead of ScrollView