Shafayat Mamun
Shafayat Mamun

Reputation: 439

My include layout in coordinate layout overlapping with another layout

I am working on a coordinator layout with a nested scroll view. I also have 3 buttons at the bottom of my screen in my layout. Now when I scroll the layout the last elements of my scroll view being overlapped with the buttons I put at the bottom. I tried using a relative layout as parent to get rid of this problem but it is still persisting. So how can I get rid of this problem?The layouts are given below:

activity_agent_profile_2:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout 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:background="#fff"
tools:context=".AgentProfileActivity2">

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#fff"
    android:fitsSystemWindows="true"
    android:layout_above="@+id/laytbtns">

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

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/agent_profile_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginBottom="125dp"
            app:expandedTitleMarginStart="118dp"
            app:expandedTitleTextAppearance="@style/expandedappbar"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#fff"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="parallax">

                <ImageView
                    android:id="@+id/backdrop"
                    android:layout_width="match_parent"
                    android:layout_height="180dp"
                    android:fitsSystemWindows="true"
                    android:scaleType="centerCrop"
                    android:src="@drawable/back" />

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="180dp"
                    android:background="#66000000">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentBottom="true"
                        android:layout_marginLeft="120dp"
                        android:orientation="vertical">

                        <TextView
                            android:id="@+id/lbl_agent_profile_position"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/lbl_agent_profile_Name"
                            android:ellipsize="end"
                            android:maxLines="1"
                            android:text="Real Estate Professional at Exit Alliance Realty"
                            android:textAppearance="?android:attr/textAppearanceSmall"
                            android:textColor="#fff"
                            android:textSize="12sp"
                            android:typeface="sans" />

                        <TextView
                            android:id="@+id/lbl_agent_profile_membersince"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Member Since: 2015"
                            android:textAppearance="?android:attr/textAppearanceSmall"
                            android:textColor="#fff"
                            android:textSize="13sp"
                            android:typeface="sans" />
                    </LinearLayout>
                </RelativeLayout>

                <ImageView
                    android:id="@+id/img_agent_profile_image"
                    android:layout_width="100dp"
                    android:layout_height="140dp"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentStart="true"
                    android:layout_marginLeft="12dp"
                    android:layout_marginStart="12dp"
                    android:scaleType="fitStart"
                    android:src="@drawable/no_profile" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/backdrop"
                    android:layout_marginLeft="5dp"
                    android:layout_toEndOf="@+id/img_agent_profile_image"
                    android:layout_toRightOf="@+id/img_agent_profile_image"
                    android:orientation="vertical">

                    <RelativeLayout
                        android:id="@+id/relativeLayout3"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="#fff">


                        <ImageView
                            android:id="@+id/imageView13"
                            android:layout_width="15dp"
                            android:layout_height="15dp"
                            android:layout_alignParentLeft="true"
                            android:layout_alignParentStart="true"
                            android:layout_centerVertical="true"
                            android:src="@drawable/ic_phone_img" />

                        <TextView
                            android:id="@+id/lbl_agent_profile_phone"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerVertical="true"
                            android:layout_marginLeft="3dp"
                            android:layout_toEndOf="@+id/imageView13"
                            android:layout_toRightOf="@+id/imageView13"
                            android:text="01723735134"
                            android:textAppearance="?android:attr/textAppearanceSmall"
                            android:textColor="#56698F"
                            android:textSize="13sp"
                            android:typeface="sans" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:id="@+id/relativeLayout4"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="#fff">


                        <ImageView
                            android:id="@+id/imageView14"
                            android:layout_width="15dp"
                            android:layout_height="15dp"
                            android:layout_alignParentLeft="true"
                            android:layout_alignParentStart="true"
                            android:layout_centerVertical="true"
                            android:src="@drawable/ic_location_nopadding" />

                        <TextView
                            android:id="@+id/lbl_agent_profile_address"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerVertical="true"
                            android:layout_marginLeft="3dp"
                            android:layout_toEndOf="@+id/imageView14"
                            android:layout_toRightOf="@+id/imageView14"
                            android:ellipsize="end"
                            android:maxLines="1"
                            android:text="2868 Al Urabuh Road, Al Urudh, Ryadh"
                            android:textAppearance="?android:attr/textAppearanceSmall"
                            android:textColor="#56698F"
                            android:textSize="12sp"
                            android:typeface="sans" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:id="@+id/relativeLayout5"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="#fff">


                        <ImageView
                            android:id="@+id/imageView15"
                            android:layout_width="15dp"
                            android:layout_height="15dp"
                            android:layout_alignParentLeft="true"
                            android:layout_alignParentStart="true"
                            android:layout_centerVertical="true"
                            android:src="@drawable/ic_website" />

                        <TextView
                            android:id="@+id/lbl_agent_profile_website"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerVertical="true"
                            android:layout_marginLeft="3dp"
                            android:layout_toEndOf="@+id/imageView15"
                            android:layout_toRightOf="@+id/imageView15"
                            android:ellipsize="end"
                            android:maxLines="1"
                            android:text="www.ibaax.com"
                            android:textAppearance="?android:attr/textAppearanceSmall"
                            android:textColor="#56698F"
                            android:textSize="12sp"
                            android:typeface="sans" />
                    </RelativeLayout>
                </LinearLayout>
            </RelativeLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:layout_marginTop="-50dp"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

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


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

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


<LinearLayout
    android:id="@+id/laytbtns"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:layout_alignParentBottom="true"
    android:background="#495B81">

    <Button
        android:id="@+id/testbutton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="1dp"
        android:layout_weight="1"
        android:background="#56688f"
        android:onClick="btnEmail_click"
        android:text="Message"
        android:textColor="#fff"
        android:textStyle="bold"
        android:typeface="sans" />

    <Button
        android:id="@+id/SMSButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="1dp"
        android:layout_weight="1"
        android:background="#56688f"
        android:onClick="btnSMS_click"
        android:text="SMS"
        android:textColor="#fff"
        android:textStyle="bold"
        android:typeface="sans" />

    <Button
        android:id="@+id/cancelButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="#56688f"
        android:onClick="btnPhone_click"
        android:text="Call"
        android:textColor="#fff"
        android:textStyle="bold"
        android:typeface="sans" />

</LinearLayout></RelativeLayout>

content_agent_profile.xml:

<android.support.v4.widget.NestedScrollView 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:background="#fff"
android:layout_gravity="fill_vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".AgentProfileActivity2"
tools:showIn="@layout/activity_agent_profile2">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <View
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:layout_marginTop="5dp"
        android:background="#d3d3d3" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:text="Specialities"
            android:textColor="#60aaff"
            android:textSize="18sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/lbl_agent_profile_specialites"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp" />

    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:layout_marginTop="5dp"
        android:background="#d3d3d3" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:text="Service Area"
            android:textColor="#60aaff"
            android:textSize="18sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/lbl_agent_profile_service"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp" />

    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:layout_marginTop="5dp"
        android:background="#d3d3d3" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:text="Profile Summery "
            android:textColor="#60aaff"
            android:textSize="18sp"
            android:textStyle="bold" />

        <WebView
            android:id="@+id/web_agentprofile_description"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:layout_marginTop="5dp"
        android:background="#d3d3d3" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:text="Active Listing"
            android:textColor="#60aaff"
            android:textSize="18sp"
            android:textStyle="bold" />

        <UI.ExpandableHeightGridView
            android:id="@+id/gridview_agent_property"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:horizontalSpacing="2dp"
            android:isScrollContainer="false"
            android:numColumns="1"
            android:stretchMode="columnWidth"
            android:verticalSpacing="2dp" />
    </LinearLayout>
</LinearLayout></android.support.v4.widget.NestedScrollView>

Here is an image of the issue: Contents in scroll view is being overlapped

Edit:

So I fixed the issue by setting a margin-bottom to 80dp in my nested scroll view. It seems to work for now but it is not a permanent solution. If anyone can come up with a better solution, I will be really grateful.

Upvotes: 1

Views: 2009

Answers (3)

Vishal Naikawadi
Vishal Naikawadi

Reputation: 493

If you're using ConstraintLayout and your included layout overlapping other views, then give your include layout height and width.

<include
            android:id="@+id/errorScreen"
            layout="@layout/error_screen_layout"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/topView"/>

Upvotes: 0

Shafayat Mamun
Shafayat Mamun

Reputation: 439

So I fixed the issue by setting a margin-bottom to 80dp in my nested scroll view. It seems to work for now but it is not a permanent solution. If anyone can come up with a better solution, I will be really grateful.

Upvotes: 0

Swapnil Kshirsagar
Swapnil Kshirsagar

Reputation: 670

<include layout="@layout/content_agent_profile"
 android:layout_above="@+id/your above layout id"
    android:layout_below="@+id/below layout id"/>

Upvotes: 3

Related Questions