0
我剛剛接觸了android開發人員,並且最近了解了片段。防止FAB在RecyclerView中滾動時出現碎片
我有內部片段recyclerview,我希望它是附着在工具欄上,我試圖把app:layout_behavior="@string/appbar_scrolling_view_behavior"
容器佈局內,但每當工具欄顯示FAB向下移動的導航欄下方,你可以看到here。
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/main_screen"
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"
tools:context="com.atar.mango.MainActivity">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/toolbar"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/logo_header"
app:menu="@menu/menu_for_navigation_view"/>
</android.support.v4.widget.DrawerLayout>
home_fragment.XML
<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"
tools:context="com.atar.mango.HomeFragment"
android:background="@color/background">
<TextView
android:id="@+id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/empty"
android:gravity="center"
android:textSize="90sp"
android:textColor="#32000000"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/notes"
app:backgroundTint="@color/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:overScrollMode="never">
</android.support.v7.widget.RecyclerView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_note"
app:backgroundTint="@color/options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginRight="@dimen/fab_margin_right"
android:layout_marginEnd="@dimen/fab_margin_right"
app:layout_anchorGravity="bottom|right|end"
android:layout_marginBottom="16dp"
android:src="@mipmap/add_note"
app:borderWidth="0dp"
android:elevation="6dp"
app:pressedTranslationZ="12dp"
app:fabSize="normal"/>
</android.support.design.widget.CoordinatorLayout>
感謝。
不會改變任何東西:( –