我的坐标布局中的包含布局与另一个布局

时间:2016-03-15 13:32:13

标签: android android-layout material-design

我正在使用嵌套滚动视图处理协调器布局。在我的布局中,我的屏幕底部还有3个按钮。现在,当我滚动布局时,滚动视图的最后一个元素与我放在底部的按钮重叠。我尝试使用相对布局作为父级来摆脱这个问题,但它仍然是持久的。那么如何摆脱这个问题?布局如下:

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>

以下是问题的图片: Contents in scroll view is being overlapped

修改

所以我通过在嵌套滚动视图中将margin-bottom设置为80dp来解决此问题。它似乎现在有效,但它不是一个永久的解决方案。如果有人能提出更好的解决方案,我将非常感激。

3 个答案:

答案 0 :(得分:5)

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

答案 1 :(得分:1)

所以我通过在嵌套滚动视图中将margin-bottom设置为80dp来解决此问题。它似乎现在有效,但它不是一个永久的解决方案。如果有人能提出更好的解决方案,我将非常感激。

答案 2 :(得分:0)

如果您使用 ConstraintLayout 并且您包含的布局与其他视图重叠,请提供您的包含布局的高度和宽度。

<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"/>