BotomSheetDialog FabButton Anchor View funktioniert nicht wie erwartet

Hi Ich versuche, die Fab-Schaltfläche in BottomSheetDialog zu verankern, aber es funktioniert nicht. EDITED Hier ist mein Dialog

public static class QuickInfoDialog extends BottomSheetDialogFragment {

        private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() {

            @Override
            public void onStateChanged(@NonNull View bottomSheet, int newState) {
                if (newState == BottomSheetBehavior.STATE_HIDDEN) {
                    dismiss();
                }

            }

            @Override
            public void onSlide(@NonNull View bottomSheet, float slideOffset) {
            }
        };


        @Override
        public void onStart() {
            super.onStart();

            // Less dimmed background; see https://stackoverflow.com/q/13822842/56285
            Window window = getDialog().getWindow();
            WindowManager.LayoutParams params = window.getAttributes();
            params.dimAmount = 0.0f; // dim only a little bit
            window.setAttributes(params);

            // Transparent background; see https://stackoverflow.com/q/15007272/56285
            // (Needed to make dialog's alpha shadow look good)
            window.setBackgroundDrawableResource(android.R.color.transparent);
        }


        @Override
        public void setupDialog(Dialog dialog, int style) {
            super.setupDialog(dialog, style);
            View contentView = View.inflate(getContext(), R.layout.location_info_sheet, null);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);

            dialog.setContentView(contentView);

            CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
            CoordinatorLayout.Behavior behavior = params.getBehavior();

            if (behavior != null && behavior instanceof BottomSheetBehavior) {
             ,   ((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
            }

//            FloatingActionButton navBtn = (FloatingActionButton) dialog.findViewById(R.id.btn_fab_direction);
//            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) navBtn.getLayoutParams();
//            int boundary = (int) (layoutParams.topMargin + (layoutParams.width * 0.5));
//            layoutParams.topMargin = boundary;
//            LogUtils.LOGD(TAG, "boundary:  " + boundary);
//            navBtn.setLayoutParams(layoutParams);
        }

        @Override
        public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
            super.onViewCreated(view, savedInstanceState);

        }
    }

Dies ist meine XML-Datei, in der meine anderen Layouts und die Fab-Schaltfläche definiert sind.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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/location_bottom_sheet"
    android:layout_width="match_parent"
    android:layout_height="196dp"
    android:background="@android:color/transparent"
    android:gravity="bottom"
    android:orientation="vertical"
    app:behavior_hideable="true"
    app:behavior_peekHeight="0dp"
    app:layout_behavior="@string/bottom_sheet_behavior"
    tools:ignore="MissingPrefix">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent">


        <FrameLayout
            android:id="@+id/clickable_sheet_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="48dp"
            android:clickable="true">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/white"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_marginBottom="@dimen/eight_dp"
                    android:layout_marginTop="@dimen/eight_dp"
                    android:layout_weight="0.3"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/image_view"
                        android:layout_width="@dimen/location_info_size"
                        android:layout_height="@dimen/location_info_size"
                        android:padding="@dimen/eight_dp"
                        android:src="@drawable/ic_launcher" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_marginBottom="@dimen/eight_dp"
                    android:layout_marginTop="@dimen/eight_dp"
                    android:layout_weight="0.7"
                    android:gravity="center"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/name_tv"
                        fontPath="@string/font_neue_pro_regular"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:padding="@dimen/four_dp"
                        android:textColor="@color/semi_black"
                        android:textSize="@dimen/sixteen_sp" />

                    <TextView
                        android:id="@+id/street_tv"
                        fontPath="@string/font_neue_pro_light"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:padding="@dimen/four_dp"
                        android:textSize="@dimen/fourteen_sp" />

                    <TextView
                        android:id="@+id/address_tv"
                        fontPath="@string/font_neue_pro_light"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:padding="@dimen/four_dp"
                        android:textSize="@dimen/fourteen_sp" />

                    <TextView
                        android:id="@+id/distance_tv"
                        fontPath="@string/font_neue_pro_light"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center_vertical|left"
                        android:padding="@dimen/four_dp"
                        android:textSize="@dimen/twelve_sp"
                        android:textColor="@color/semi_grey"/>
                </LinearLayout>
            </LinearLayout>
        </FrameLayout>

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/btn_fab_direction"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:src="@drawable/ic_directions_white"
            app:layout_anchor="@id/app_bar_layout"
            app:layout_anchorGravity="bottom|end" />

    </FrameLayout>
</LinearLayout>

Ich habe versucht, Lösung von hier Android BottomSheet mit FloatButton aber es hat nicht funktioniert

Fragment Layout, aus dem ich dieses BottomSheet zeige.

<?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/coordinatorLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:focusable="true"
    android:focusableInTouchMode="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">



        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_gravity="bottom"
            android:background="@color/style_color_accent" />
    </android.support.design.widget.AppBarLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <FrameLayout
            android:id="@+id/map_main_fragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/sixteen_dp"
            android:focusable="false"
            android:focusableInTouchMode="false">

            <LinearLayout
                android:id="@+id/layout_search_filter"
                android:layout_width="match_parent"
                android:layout_height="48dp"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/search_input_tv"
                    fontPath="@string/font_neue_pro_light"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="0.85"
                    android:background="@drawable/bg_shadow_layout"
                    android:elevation="@dimen/eight_dp"
                    android:gravity="center|left"
                    android:hint="@string/search_input_et_hint"
                    android:paddingLeft="@dimen/eight_dp"
                    android:textColor="@color/semi_black"
                    android:textColorHint="@color/semi_grey"
                    android:textSize="@dimen/fourteen_sp" />

                <ImageView
                    android:id="@+id/location_filter_selector_iv"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="@dimen/eight_dp"
                    android:layout_weight="0.15"
                    android:background="@drawable/bg_shadow_layout"
                    android:elevation="@dimen/eight_dp"
                    android:padding="@dimen/twelve_dp"
                    android:src="@drawable/ic_filter_grey" />

            </LinearLayout>

        </RelativeLayout>

    </FrameLayout>

    <include layout="@layout/location_info_sheet" />

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

Antworten auf die Frage(2)

Ihre Antwort auf die Frage