2016-10-17 2 views
2

ich die folgende Layout xml für meine TätigkeitWie FAB zu verhindern, dass mit CoordinateLayout in Android-Scrolling

<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:background="@color/white" 
    android:fitsSystemWindows="true" 
    tools:context=".HomeActivity"> 

    <android.support.design.widget.AppBarLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:theme="@style/AppTheme.Dark.AppBarOverlay" 
      app:elevation="0dp"> 

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

    <RelativeLayout 
     android:id="@+id/rl_updates" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/ll_footer" 
     android:layout_below="@+id/ll_fibres_search"> 

     <android.support.v4.widget.SwipeRefreshLayout 
       android:id="@+id/srl_updates" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

       <android.support.v7.widget.RecyclerView 
        android:id="@+id/rv_all_requirements" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:divider="@color/iron" 
        android:dividerHeight="1px"/> 
     </android.support.v4.widget.SwipeRefreshLayout> 

     <android.support.design.widget.FloatingActionButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:layout_alignParentEnd="true" 
       android:layout_alignParentRight="true" 
       android:layout_marginBottom="@dimen/activity_horizontal_margin" 
       android:layout_marginEnd="@dimen/activity_horizontal_margin" 
       android:layout_marginRight="@dimen/activity_horizontal_margin" 
       android:onClick="onRequirement" 
       android:overScrollMode="never" 
       android:src="@drawable/ic_playlist_add_white_24dp" 
       app:backgroundTint="@color/pink"/> 
    </RelativeLayout> 
</android.support.design.widget.CoordinatorLayout> 

habe Wenn ich die Recycler Ansicht scrollen, kollabiert die App Bar genauso wie ich es sein wollte. Aber das Problem ist, dass der FAB auch ein wenig nach unten schaltet. Ich setze 16dp Rand nach unten, aber es bleibt an der Unterseite des Bildschirms.

Wie verhindere ich, dass der FAB anfänglich heruntergeschaltet wird?

Dies ist, wie es jetzt enter image description here

Antwort

1

Haben Sie versucht, die FloatingActionButton außerhalb des RelativeLayout und innerhalb der CoordinatorLayout zu nehmen? Sie können das tun und geben ihm das Attribut:

android:layout_gravity="bottom|right|end" 

statt:

android:layout_alignParentBottom="true" 
    android:layout_alignParentEnd="true" 
    android:layout_alignParentRight="true" 
0

Satz Anker für Ihre FAB-Taste

app aussieht: layout_anchorGravity = "bottom | right | Ende" android: layout_gravity = "right"

+0

Diese nicht –

+0

die FAB-Taste innerhalb eines releative Layout verwenden funktioniert und den obigen Code zu tun und geben Marge der Knopf – Sam

0

ersetzen mit FrameLayout und fügen Sie diese Zeile zu Ihrem FAB hinzu

android: layout_gravity = "right | bottom"

wie diese

<FrameLayout 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <android.support.v4.widget.SwipeRefreshLayout 
     android:id="@+id/srl_updates" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/rv_all_requirements" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
android:divider="@color/iron" 
      android:dividerHeight="1px"/> 
    </android.support.v4.widget.SwipeRefreshLayout> 

    <android.support.design.widget.FloatingActionButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="@dimen/activity_horizontal_margin" 
     android:layout_marginEnd="@dimen/activity_horizontal_margin" 
     android:layout_marginRight="@dimen/activity_horizontal_margin" 
     android:onClick="onRequirement" 
     android:layout_gravity="right|bottom" 
     android:overScrollMode="never" 
     android:src="@drawable/ic_playlist_add_white_24dp" 
     app:backgroundTint="@color/pink"/> 

</FrameLayout> 
+0

Das funktioniert nicht. –

Verwandte Themen