2017-08-26 52 views
0

click here to view image如何可以放置在特定的位置

如何可以放置爲浮動按鈕所示圖像位置的浮動按鈕。下面是我的XML代碼

<android.support.design.widget.CoordinatorLayout 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"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/rec_summary_recycler_view_inflow" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scrollbarSize="5dp" 
    android:scrollbars="vertical" 
    android:scrollbarThumbVertical="@drawable/scr"/> 


<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|right" 
    android:backgroundTint="@color/colorPrimary" 
    android:src="@drawable/down_arrow" 
    android:layout_margin="25dp" 
    app:fabSize="mini" 
    android:onClick="Scroll" /> 

+0

刪除當前layout_margin並添加layout_marginBottom =「40dp」 – MrCurious

+0

它去的屏幕 –

+0

的底端再加入marginBottom = 40dp和marginEnd = 40dp,調整根據DP的您的需要 – MrCurious

回答

0

嘗試在工廠添加此行。根據您的需求改變價值。這條線將設置一個晶圓廠到屏幕的右下角。

android:layout_alignParentBottom="true" 
android:layout_alignParentEnd="true" 
android:layout_alignParentRight="true" 
android:layout_gravity="end|bottom" 
+0

其工作正常 –

+0

我怎樣才能知道RecyclerView滾動條的可見性是真是假 –

+0

@RakeshKadadhi請詳細說明你的問題! –

0

使用這個隱藏顯示在recyclerview滾動晶圓廠

recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() 
{ 
    @Override 
    public void onScrolled(RecyclerView recyclerView, int dx, int dy) 
    { 
     if (dy > 0 ||dy<0 && fab.isShown()) 
     { 
      fab.hide(); 
     } 
    } 

@Override 
public void onScrollStateChanged(RecyclerView recyclerView, int newState) 
{ 
    if (newState == RecyclerView.SCROLL_STATE_IDLE) 
    { 
     fab.show(); 
    } 

    super.onScrollStateChanged(recyclerView, newState); 
} 
}); 
+0

好吧,我會檢查它。 –

+0

感謝Janish,它的工作很好。 –

+0

嗨Jenish,我怎樣才能讓它在屏幕上移動。 –

0

給一個id你content_layout.xml(ID:layout_content),並使用應用程序:layout_anchor =「@ ID/layout_content 「在你的晶圓廠佈局。

<include layout="@layout/content_order_list" 
    android:id="@+id/layout_content"/> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:layout_anchor="@id/layout_content" 
    app:layout_anchorGravity="bottom|end" 
    android:layout_marginBottom="90dp" 
    android:layout_marginEnd="@dimen/activity_horizontal_margin" 
    android:layout_marginRight="@dimen/activity_horizontal_margin" 
    app:srcCompat="@android:drawable/ic_dialog_email" />