2016-03-15 111 views
2

我正在使用嵌套滾動視圖處理協調器佈局。在我的佈局中,我的屏幕底部也有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來解決了該問題。它似乎現在工作,但它不是一個永久的解決方案。如果有人能想出更好的解決方案,我會非常感激。

回答

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

我的包含佈局位於協調器佈局內部。所以相對佈局的layout_above或layout_below /屬性在coordiante佈局中不起作用。 –

1

所以我通過在我的嵌套滾動視圖中將margin-bottom設置爲80dp來解決了這個問題。它似乎現在工作,但它不是一個永久的解決方案。如果有人能想出更好的解決方案,我會非常感激。