2017-12-04 13 views
0

スクロールバーの下端を非表示にしたいが、FABは画面上にとどまるべきである。CoordinatorLayout内のFloatingActionButtonを使用したBottomNavigationViewの位置が一致しない

FABをアンカーを使用してBottomNavigationViewの上に置くと、その背後に表示されます。

BottomNavigationViewに設定しても動作しますが、テストは失敗します(https://issuetracker.google.com/issues/70162122)ので、現時点では使用できません。

enter image description here

レイアウト:

<?xml version="1.0" encoding="utf-8"?> 
<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:id="@+id/mainLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context=".screens.main.MainActivity"> 

    <FrameLayout 
    android:id="@+id/mainContainer" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/scrolling_view_behaviour" /> 

    <android.support.design.widget.FloatingActionButton 
    android:id="@+id/mainNewQuestionButton" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_margin="@dimen/spacing_8dp" 
    app:layout_anchor="@+id/mainBottomNavigationView" 
    app:layout_anchorGravity="top|right|end" 
    app:srcCompat="@drawable/create_question" 
    tools:visibility="visible" /> 

    <android.support.design.widget.BottomNavigationView 
    android:id="@+id/mainBottomNavigationView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:itemBackground="@color/my_gray" 
    app:itemIconTint="@drawable/selector_bottombar_item" 
    app:itemTextColor="@drawable/selector_bottombar_item" 
    app:layout_anchor="@id/mainContainer" 
    app:layout_anchorGravity="bottom" 
    app:layout_behavior="@string/hide_bottom_navigation_view_behaviour" 
    app:menu="@menu/bottom_navigation_main" /> 

</android.support.design.widget.CoordinatorLayout> 

答えて

0

あなたはここにZ-Ordering問題を抱えているようです。あなたは、私が前に、私はこのプロジェクトのために書いたFABの一連からなる、カスタムFloatingActionMenuをもたらすために、これらのメソッドを使用し21、および21

上記のAPIのためのViewCompat.setZ(fab, someFloat)以下のAPIのためfab.invalidate()続いfab.bringToFront()を試みることができる 画面上のすべてが重なって表示されます。

関連する問題