Потрясающая панель не отображается поверх вложенной прокрутки

Я следил за многими ответами и пытался показать потрясающую панель поверх вложенной прокрутки, но мне не удалось этого добиться.

мой xml

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
>


    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nested_scroll_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        android:fillViewport="true"
        android:scrollbars="none"
        android:scrollingCache="true">
        <LinearLayout
            android:id="@+id/billBlock"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/allJobsheetList"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            </android.support.v7.widget.RecyclerView>


        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end|right"
        android:gravity="center_horizontal"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:orientation="vertical">


        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab_mic"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/spacing_middle"
            android:clickable="true"
            android:tint="@color/grey_80"
            app:backgroundTint="@color/grey_20"
            app:fabSize="mini"
            app:rippleColor="@android:color/white"
            app:srcCompat="@drawable/ic_mic" />

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab_call"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/spacing_middle"
            android:clickable="true"
            android:tint="@color/grey_80"
            app:backgroundTint="@color/grey_20"
            app:fabSize="mini"
            app:rippleColor="@android:color/white"
            app:srcCompat="@drawable/ic_photo_camera" />

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/showFilterView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/spacing_smlarge"
            android:layout_marginLeft="@dimen/spacing_smlarge"
            android:layout_marginRight="@dimen/spacing_smlarge"
            android:layout_marginTop="@dimen/spacing_middle"
            android:clickable="true"
            android:tint="@android:color/white"
            app:fabSize="normal"
            app:rippleColor="@android:color/white"
            app:srcCompat="@drawable/ic_add" />

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

в приведенной выше панели xml fab, отображаемой в конце вложенного представления прокрутки, не в фиксированном положении внизу справа. Я новичок в Android, может ли кто-нибудь помочь мне, как я могу этого добиться

Как добавить плавающую кнопку действия поверх прокрутки

Создайте макет с помощью CardView и плавающей кнопки действия Android

FrameLayout не соответствует высоте NestedScrollView


person scott    schedule 04.08.2018    source источник
comment
выравнивание родительского элемента по нижнему краю и выравнивание родительского элемента по правому краю используются в относительных макетах для фиксации представлений внизу/справа соответственно. В этом случае это не фиксирует вид, вы можете добавить поле снизу к вложенному прокрутке и соответственно задать высоту линейного макета.   -  person Kaveri    schedule 04.08.2018
comment
Чтобы выровнять дочерний элемент относительно другого в макете координатора, используйте привязку или гравитацию макета, чтобы придать ему гравитацию, и, чтобы воспользоваться преимуществами поведения координатора, сделайте потрясающие прямыми дочерними элементами макета координатора.   -  person Kaveri    schedule 04.08.2018
comment
@Kaveri.можете ли вы предоставить образец кода.спасибо   -  person scott    schedule 04.08.2018


Ответы (2)


Сделал несколько изменений, сделал fab прямым потомком макета координатора и использовал archor app:layout_anchor="@id/nested_scroll_view" app:layout_anchorGravity="bottom|right|end" и для выравнивания fabs относительно вложенного прокрутки.

`<android.support.design.widget.CoordinatorLayout
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="match_parent"
android:background="@android:color/white"
>
<android.support.v4.widget.NestedScrollView
    android:id="@+id/nested_scroll_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:scrollbars="none"
    android:scrollingCache="true">
    <LinearLayout
        android:id="@+id/billBlock"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/allJobsheetList"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        </android.support.v7.widget.RecyclerView>

    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

<!--<LinearLayout-->
    <!--android:layout_width="wrap_content"-->
    <!--android:layout_height="wrap_content"-->
    <!--android:gravity="center_horizontal"-->

    <!---->
    <!--android:orientation="vertical">-->


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_mic"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_anchor="@id/nested_scroll_view"
        app:layout_anchorGravity="bottom|right|end"
        android:layout_marginRight="10dp"
        android:clickable="true"
        android:layout_marginBottom="130dp"
        app:fabSize="mini"
        app:rippleColor="@android:color/white"
        android:src="@drawable/ic_launcher_background" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_call"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp"
        android:clickable="true"
        android:layout_marginBottom="70dp"
        app:layout_anchor="@id/nested_scroll_view"
        app:layout_anchorGravity="bottom|right|end"
        app:fabSize="mini"

        app:srcCompat="@drawable/exo_controls_play" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/showFilterView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_anchor="@id/nested_scroll_view"
        app:layout_anchorGravity="bottom|right|end"
        android:clickable="true"
        android:tint="@android:color/white"
        app:fabSize="normal"
        app:rippleColor="@android:color/white"
        app:srcCompat="@drawable/exo_controls_next" />
<!--</LinearLayout>-->
</android.support.design.widget.CoordinatorLayout>
person Kaveri    schedule 07.08.2018
comment
@Kaveri.Спасибо, я уже сделал это, но теперь моя проблема в том, что мне нужно скрыть нижний вид навигации при прокрутке, но у меня есть вложенная прокрутка в каждом фрагменте - person scott; 08.08.2018
comment
Извините за поздний ответ, так вы имеете в виду скрыть (анимировать) нижнюю полосу при прокрутке и показать ее при обратной прокрутке? - person Kaveri; 08.08.2018
comment
@Kaveri.да, совершенно верно. Прежде чем я сделал это, используя макет кадра внутри вложенной прокрутки, но если я добавлю это, то мой потрясающий не будет правильно расположен - person scott; 09.08.2018
comment
Один из способов добиться такого поведения — установить layout_behaviour для нижней панели, но для этого требуется макет координатора в качестве корневого родителя. Эта ссылка может вам помочь:-stackoverflow.com/questions/34715732/ - person Kaveri; 09.08.2018

Этот макет будет работать нормально. Пожалуйста, проверьте, есть ли у вас ic_add, ic_mic, ic_photo_camera в папке res/drawable. Удалив их, я вижу вид, как показано ниже скриншот

person Viswanath Kumar Sandu    schedule 04.08.2018
comment
я вижу значок, но если у вас есть большие строки содержимого в прокрутке, он отображается в конце ciew - person scott; 04.08.2018